T
TanStack6d ago
judicial-coral

[RC] Cloudflare-vite unable to run dev server and build

I'm unable to run the dev server after upgrading to RC. The issue seems to be related to the getSession in the root's beforeLoad. https://github.com/khashvin/tss-cloudflare/blob/master/src/routes/root.tsx#L16 How can I fix this? Am I missing something? repro: https://github.com/khashvin/tss-cloudflare
✘ [ERROR] Could not resolve "sqlite"

node_modules/.pnpm/wrangler@4.40.2/node_modules/wrangler/wrangler-dist/cli.js:17007:33:
17007 │ DatabaseSync = require("sqlite").DatabaseSync;
╵ ~~~~~~~~

You can mark the path "sqlite" as external to exclude it from the bundle, which will remove this
error and leave the unresolved path in the bundle. You can also surround this "require" call with
a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "./node.js"

node_modules/.pnpm/blake3-wasm@2.1.5/node_modules/blake3-wasm/esm/index.js:13:14:
13 │ export * from './node.js';
╵ ~~~~~~~~~~~

7:47:21 PM [vite] (ssr) warning: Automatically externalized node built-in module "node:sqlite" imported from "node_modules/.pnpm/undici@7.14.0/node_modules/undici/lib/cache/sqlite-cache-store.js". Consider adding it to environments.ssr.external if it is intended.
Plugin: vite:resolve
✘ [ERROR] Cannot read file: /home/khk/workspaces/tss-cloudflare/node:sqlite

node_modules/.pnpm/undici@7.14.0/node_modules/undici/lib/cache/sqlite-cache-store.js:113:29:
113 │ DatabaseSync = require('node:sqlite').DatabaseSync
╵ ~~~~~~~~~~~~~

7:47:21 PM [vite] (ssr) error while updating dependencies:
Error: Error during dependency optimization:

✘ [ERROR] Could not resolve "./node.js"

node_modules/.pnpm/blake3-wasm@2.1.5/node_modules/blake3-wasm/esm/index.js:13:14:
13 │ export * from './node.js';
╵ ~~~~~~~~~~~
✘ [ERROR] Could not resolve "sqlite"

node_modules/.pnpm/wrangler@4.40.2/node_modules/wrangler/wrangler-dist/cli.js:17007:33:
17007 │ DatabaseSync = require("sqlite").DatabaseSync;
╵ ~~~~~~~~

You can mark the path "sqlite" as external to exclude it from the bundle, which will remove this
error and leave the unresolved path in the bundle. You can also surround this "require" call with
a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "./node.js"

node_modules/.pnpm/blake3-wasm@2.1.5/node_modules/blake3-wasm/esm/index.js:13:14:
13 │ export * from './node.js';
╵ ~~~~~~~~~~~

7:47:21 PM [vite] (ssr) warning: Automatically externalized node built-in module "node:sqlite" imported from "node_modules/.pnpm/undici@7.14.0/node_modules/undici/lib/cache/sqlite-cache-store.js". Consider adding it to environments.ssr.external if it is intended.
Plugin: vite:resolve
✘ [ERROR] Cannot read file: /home/khk/workspaces/tss-cloudflare/node:sqlite

node_modules/.pnpm/undici@7.14.0/node_modules/undici/lib/cache/sqlite-cache-store.js:113:29:
113 │ DatabaseSync = require('node:sqlite').DatabaseSync
╵ ~~~~~~~~~~~~~

7:47:21 PM [vite] (ssr) error while updating dependencies:
Error: Error during dependency optimization:

✘ [ERROR] Could not resolve "./node.js"

node_modules/.pnpm/blake3-wasm@2.1.5/node_modules/blake3-wasm/esm/index.js:13:14:
13 │ export * from './node.js';
╵ ~~~~~~~~~~~
4 Replies
other-emerald
other-emerald6d ago
you have to install better-sqlite3cause locally, its use a sqlite file
judicial-coral
judicial-coralOP6d ago
same issue after installing it. it was working before this with D1 locally before I upgraded to RC
other-emerald
other-emerald6d ago
get rid of bindings.ts get env like this `import { env } from 'cloudflare:workers';``
judicial-coral
judicial-coralOP6d ago
yep that was the issue. Thanks! @stunaz

Did you find this page helpful?