framework
framework copied to clipboard
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.output/server/node_modules/node-fetch-native/dist/polyfill.mjs'
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:
[email protected]
- Builder:
vite
- User Config:
ssr
,app
,css
,buildModules
,build
,nitro
,runtimeConfig
- Runtime Modules:
-
- Build Modules:
[email protected]
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
Upstream issue created:
- https://github.com/unjs/nitro/issues/526
You can workaround this issue for now by ensuring you have only one version of node-fetch-native
in your package lockfile. (The issue is a regression in nitro's traced externals which ignores the polyfill from a lower version in parent directory in favour of other files in a sub dependency of nitro.)
cc: @pi0
Started to have same error recently.
Here's a minimal reproduction: https://stackblitz.com/edit/github-1nqt6s.
Hi @danielroe So what is the specific workaround? Do we need to add node-fetch-native
to the package.json of our Nuxt project at the version specified in your repro?
Yes; you can run npm i node-fetch-native
.
Ok cool, so just to confirm, that doesn't fix the issue for me, unfortunately.
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.
For me it helped to remove yarn.lock
and generate new one from scratch.
Ok, looks like ohmyfetch was the culprit, I have bumped this version and seems to be good.
Reopening until we resolve in nitropack - you can follow https://github.com/unjs/nitro/pull/529.
I'm just now running into this issue using nuxt bridge "@nuxt/bridge": "npm:@nuxt/bridge-edge@^3.0.0-27747000.69db93e"
(latest as of this writing). I've bumped ohmyfetch and tried to install just node-fetch-native to no avail