Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with imports: ERR_MODULE_NOT_FOUND #344

Closed
P4sca1 opened this issue May 11, 2022 · 7 comments
Closed

Problems with imports: ERR_MODULE_NOT_FOUND #344

P4sca1 opened this issue May 11, 2022 · 7 comments

Comments

@P4sca1
Copy link

P4sca1 commented May 11, 2022

Environment

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)
@Tcharlyson
Copy link

Tcharlyson commented Jun 1, 2022

I reproduce exactly the same, my workaround is to fix the ufo version of all dependencies directly at the end of my package.json:

With yarn

...
"resolutions": {
   "ufo": "^0.8.4"
}

Do not forget to yarn install again.

Hope this helps until a solution !

@relisora
Copy link

relisora commented Jun 2, 2022

The npm equivalent doesn't seem to work though, I replaced resolutions with overrides

@danielroe
Copy link
Member

Is this still an issue for you? I cannot reproduce it.

@dargmuesli
Copy link
Member

dargmuesli commented Jul 4, 2022

It indeed looks very much fixed to me (and my projects)! <3

@P4sca1
Copy link
Author

P4sca1 commented Jul 5, 2022

After refreshing my lock file to upgrade all dependencies, I can confirm that the issue is gone.

@P4sca1
Copy link
Author

P4sca1 commented Jul 5, 2022

@danielroe Instead of the ufo related import error, I now get similar errors such as

[nuxt] [request error] Cannot find module '[omitted]/.output/server/node_modules/lodash/isPlainObject' imported from [omitted]/.output/server/chunks/app/server.mjs
Did you mean to import lodash/isPlainObject.js?
  at new NodeError (node:internal/errors:371:5)  
  at finalizeResolution (node:internal/modules/esm/resolve:416:11)  
  at moduleResolve (node:internal/modules/esm/resolve:932:10)  
  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)

After a few seconds, the app crashes with a JavaScript heap out of memory error.

@danielroe
Copy link
Member

See nuxt/nuxt#13404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants