qwik
qwik copied to clipboard
Cannot bundle Node.js built-in "node:http", due to node-fetch dep
Qwik Version
v0.9.0
Operating System (or Browser)
OSX
Node Version (if applicable)
v16.3.0
Which component is affected?
Qwik Rollup / Vite plugin
Expected Behaviour
The preview command builds and previews the application
Actual Behaviour
The preview command fails with
[commonjs--resolver] Cannot bundle Node.js built-in "node:http" imported from "node_modules/node-fetch/src/index.js". Consider disabling ssr.noExternal or remove the built-in dependency.
error during build:
Error: Cannot bundle Node.js built-in "node:http" imported from "node_modules/node-fetch/src/index.js". Consider disabling ssr.noExternal or remove the built-in dependency.
at error (file:///Users/yoroshi/projects/web/qwik-app/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at throwPluginError (file:///Users/yoroshi/projects/web/qwik-app/node_modules/rollup/dist/es/shared/rollup.js:21781:12)
at Object.error (file:///Users/yoroshi/projects/web/qwik-app/node_modules/rollup/dist/es/shared/rollup.js:22503:20)
at Object.resolveId (file:///Users/yoroshi/projects/web/qwik-app/node_modules/vite/dist/node/chunks/dep-a713b95d.js:34356:34)
at Object.handler (file:///Users/yoroshi/projects/web/qwik-app/node_modules/vite/dist/node/chunks/dep-a713b95d.js:45961:19)
at file:///Users/yoroshi/projects/web/qwik-app/node_modules/rollup/dist/es/shared/rollup.js:22710:40
Occurs after Vite ✓ Built client modules
Additional Information
To reproduce simply create a new qwik app using the creator and add a integration with cloudflare-pages or netlify-edge
npm create qwik@latest
# Create basic
cd qwik-app
npm run qwik add cloudflare-pages # or netlify-edge
npm run preview
This only seems to effect the edge function integrations.
I have the same issue
The repo is here: https://github.com/philwolstenholme/lasttramfrom-qwik
I had the same issue
The repo is here: https://github.com/gang-of-front/realworld-qwik
I changed vite.config.ts and add "type": "module" in package.json the preview works for me
// => vite.config.ts || noExternal: undefined
export default defineConfig(() => {
return {
ssr: { target: "webworker", noExternal: undefined },
plugins: [qwikCity(), qwikVite(), tsconfigPaths()],
};
});
{
"name": "my-qwik-basic-starter",
"description": "Recommended for your first Qwik app",
"engines": {
"node": ">=15.0.0"
},
"type": "module",
}
just remove the netlifyEdge(...) config from vite.config.ts file is sufficient to overcome it on my side 👍
I'm experiencing the same with 0.11.1.
Rafael's suggestion didn't fix it for me
Having the same issue on 0.11.1
Thanks for opening the issue. With how how the vite.config was being shared caused issues similar to this, which is why the latest updates recommends using the adaptors and vite configs specifically for each server. I verified the updates worked on the example repo from @rafaellucio.
- Update to the latest version of
@builder.io/qwikand@builder.io/qwik-city - Run
npm run qwik add - Add the "Adaptor" you'll be using, such as "Adaptor: Cloudflare Pages (serverless)"
- A new vite config will be created:
adaptors/cloudflare-pages/vite.config.ts - Your package.json
build.serverwill be updated tovite build -c adaptors/cloudflare-pages/vite.config.ts
Additionally, in the root vite.config.ts, you'll be able to remove the ssr property, since it's now included in the cloudflare specific vite config:
export default defineConfig(() => {
return {
- ssr: { target: "webworker", noExternal: true },
plugins: [qwikCity(), qwikVite(), tsconfigPaths()],
};
});
Hope that helps and please reopen a new issue if you're still have troubles. Thanks