#Internal server error: Cannot find module 'bun:sqlite'
17 messages · Page 1 of 1 (latest)
I can build and serve and I get no errors and seem to work if I add this to the vite.config.ts for the bun adapter.
build: {
ssr: true,
rollupOptions: {
input: ["src/entry.bun.ts", "@qwik-city-plan"],
external: ['bun:sqlite']
},
minify: true,
},
However, if I add this in the vite.config.ts that is being run when starting, it has no effect and I still get the errors.
Maybe in optimizedeps? https://github.com/BuilderIO/qwik/blob/c161bfdbaca9da85273d2a517e432aec9e651168/starters/apps/base/vite.config.ts#L24
Hi! Thanks for the answer.
I tried adding:
optimizeDeps: {
exclude: ['bun:*']
},
But I still get errors:
Pre-transform error: Failed to load url bun:sqlite (resolved id: bun:sqlite) in /node_modules/mytestdb/service/db.js. Does the file exist?
:36:08 PM [vite] Error when evaluating SSR module /node_modules/mytestdb/service/db.js: failed to import "bun:sqlite"
I wonder if vite does not read the types that are defined in the tsconfig...
If I import the package dynamically in a function:
export init = () => { const sqlite = await import('bun:sqlite'); // No SSR evaluating errors }
I'm not sure if it takes a regex, but yours isn't even a regex. Put either /^bun:/ or the full package names
This is put in the vite.config.ts in qwik root.
Does not seem to work.
Also i notice when I load it dynamically I don't get the evaluating errors, but i still get error when i load it:
I tried
bun --bun run vite
But then I get errors with node, like crypto.
However, if I build and run serve with the bun adapter it works.
🐼 error [❌] Error: Cannot find module 'bun:sqlite' imported from 'node_modules/mytestdb/service/db.js'
at nodeImport (file:///node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:54928:25)
at ssrImport (file:///node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:54837:30)
at ssrDynamicImport (file:///node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:54870:16)
at Module.get (node_modules/mytestdb/service/db.js:11:33)
at Module.vssSearch (node_modules/mytestdb/service/products.js:8:38)
at Module.search (node_modules/mytestdb/index.js:25:48)
at Object.eval (src/root.tsx:78:35)
at Object.invokeApply (node_modules/@builder.io/qwik/core.mjs:3627:22)
at Object.invoke (node_modules/@builder.io/qwik/core.mjs:3620:22)
at eval (node_modules/@builder.io/qwik/core.mjs:7206:25)
6:04:14 PM [vite] ✨ new dependencies optimized: system-styles/panda/css, @agapi/panda/jsx
Looks maybe this is related to pandacss?
I have removed panda now.
I still get errors, the following:
file:///node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:54928
const err = new Error(Cannot find module '${id}' imported from '${importer}');
^
Error: Cannot find module 'bun:sqlite' imported from 'node_modules/mydbtest/service/db.js'
at nodeImport ...
What is the error
The error I get now is when running vite:
[vite] Internal server error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'bun:'