question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with imports: ERR_MODULE_NOT_FOUND

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Jul 5, 2022
1reaction
P4sca1commented, Jul 5, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found