Problems with imports: ERR_MODULE_NOT_FOUND
See original GitHub issueEnvironment
Nuxt CLI v3.0.0-rc.3-27536597.3359b3b RootDir: /sandbox Nuxt project info:
- Operating System:
Linux
- Node Version:
v14.18.1
- Nuxt Version:
2.16.0-27358576.777a4b7f
- Package Manager:
yarn@1.22.17
- Builder:
webpack
- User Config:
bridge
,buildModules
- Runtime Modules:
-
- Build Modules:
@nuxt/bridge@3.0.0-27530716.c4f8671
Reproduction
https://codesandbox.io/s/async-platform-s1qn8l
Open a new terminal and run yarn build
, followed by yarn start
.
Describe the bug
The app works fine in development, but is not working after building.
yarn build
, followed by yarn start
does not work.
Additional context
I noticed that the ufo
package is missing a package.json
, which might be the reason for the issue.
In my private app, I replaced all import of ufo
with ufo/dist/index.mjs
, which fixed the error for ufo
, but reveiled additional import related errors.
Logs
sandbox@sse-sandbox-s1qn8l:/sandbox$ node .output/server/index.mjs
internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/sandbox/.output/server/node_modules/ufo/' imported from /sandbox/.output/server/index.mjs
Did you mean to import ufo/dist/index.cjs?
at new NodeError (internal/errors.js:322:7)
at legacyMainResolve (internal/modules/esm/resolve.js:245:9)
at packageResolve (internal/modules/esm/resolve.js:680:14)
at moduleResolve (internal/modules/esm/resolve.js:728:18)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
at Loader.resolve (internal/modules/esm/loader.js:89:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
at link (internal/modules/esm/module_job.js:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
[nuxt] [request error] Cannot find package '/Users/pascal/code/ips-hosting/frontend/.output/server/node_modules/graphql/' imported from /Users/pascal/code/ips-hosting/frontend/.output/server/chunks/app/server.mjs
at new NodeError (node:internal/errors:371:5)
at legacyMainResolve (node:internal/modules/esm/resolve:335:9)
at packageResolve (node:internal/modules/esm/resolve:877:14)
at moduleResolve (node:internal/modules/esm/resolve:929:18)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36)
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
This answer was the one that helped me! I was using import and the file was .js - Adding --es-module-specifier-resolution=node saved the day...
Read more >ERR_MODULE_NOT_FOUND for project-level module #3163
Adding the .js extension on the import lines resolves the issue. It is a weird error but I think we have to provide...
Read more >ERR_MODULE_NOT_FOUND on importing of installed ...
ERR_MODULE_NOT_FOUND on importing of installed package for using as a type in JSDoc. What steps will reproduce the issue? 1. I use pdfmake...
Read more >module-not-found - Next.js
The module you're trying to import is not installed in your dependencies ... When importing a module from npm this module has to...
Read more >Cannot find module 'C:\path1' imported from C:\path2 - Dirask
You probably didn't specify the file extension. When you are using ES Modules import/export in pure JS in Node.js, you need to remember...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
See https://github.com/nuxt/framework/issues/3343.
After refreshing my lock file to upgrade all dependencies, I can confirm that the issue is gone.