nuxt: Cannot find 'node-fetch-native/dist/polyfill.mjs' with production build
Environment
Nuxi 3.0.0-rc.12-27729267.0640a6c
- Operating System:
Darwin - Node Version:
v16.14.2 - Nuxt Version:
3.0.0-rc.12-27729267.0640a6c - Nitro Version:
0.5.4-27726613.640c2b7 - Package Manager:
pnpm@7.9.0 - Builder:
vite - User Config:
ssr,app,css,buildModules,build,nitro,runtimeConfig - Runtime Modules:
- - Build Modules:
nuxt-windicss@2.5.1
Reproduction
I can provide a reproduction if required … but this seems to be happening on both rc-11, rc-12 and latest …
Describe the bug
After running pnpm run build on my project, I am seeing the following stack trace when starting the node server (either using node ./server/index.mjs or pnpm preview) …
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/michael/Developer/observerly/sirius/apps/www/.output/server/node_modules/node-fetch-native/dist/polyfill.mjs' imported from /Users/michael/Developer/observerly/sirius/apps/www/.output/server/index.mjs
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:418:11)
at moduleResolve (node:internal/modules/esm/resolve:983:10)
at defaultResolve (node:internal/modules/esm/resolve:1080:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
at link (node:internal/modules/esm/module_job:78:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 17 (8 by maintainers)
This still occurs for me with nitropack 2.4.0 on netlify with
pnpm build. Resolution was to usein package.json to restrict to the highest version that was being included.
Nuxt 3.6 same problem
This should now be resolved in nitropack 0.6.1 and rc13.
For me it helped to remove
yarn.lockand generate new one from scratch.Here’s a minimal reproduction: https://stackblitz.com/edit/github-1nqt6s.
Started to have same error recently.
Ok, looks like ohmyfetch was the culprit, I have bumped this version and seems to be good.
The issue is multiple versions installed rather than a specific version number; check your lockfile to see what they are and why. You may also be able to resolve with npm overrides.
Yes; you can run
npm i node-fetch-native.