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

nuxi upgrade does not work any longer: Cannot find module #675

Open
ahoiroman opened this issue Jan 15, 2025 · 6 comments · May be fixed by #688
Open

nuxi upgrade does not work any longer: Cannot find module #675

ahoiroman opened this issue Jan 15, 2025 · 6 comments · May be fixed by #688

Comments

@ahoiroman
Copy link

ahoiroman commented Jan 15, 2025

Environment

Reproduction

-

Describe the bug

If I run nuxi upgrade, the following happens:

~/Entwicklung/Nuxt/example-frontend git:[next_gen]
nuxi upgrade
[nuxi 1:39:01 PM] ℹ Package manager: pnpm 9.15.3
[nuxi 1:39:01 PM] ℹ Current Nuxt version: 3.15.1

✔ Would you like to recreate node_modules and pnpm-lock.yaml to
fix problems with hoisted dependency versions and ensure you
have the most up-to-date dependencies?
Yes
[nuxi 1:39:02 PM] ℹ Recreating node_modules and pnpm-lock.yaml. If you encounter any issues, revert the changes and try with --no-force
[nuxi 1:39:05 PM] ℹ Installing latest stable Nuxt 3 release...

[1:39:05 PM]  ERROR  Cannot find module '/Users/ahoi/Entwicklung/Nuxt/example-frontend/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/main.mjs' imported from /Users/ahoi/Entwicklung/Nuxt/example-frontend/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.u_uB65ir.mjs

    at finalizeResolution (node:internal/modules/esm/resolve:265:11)
    at moduleResolve (node:internal/modules/esm/resolve:933:10)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
    at ModuleLoader.import (node:internal/modules/esm/loader:472:34)
    at defaultImportModuleDynamicallyForModule (node:internal/modules/esm/utils:214:31)
    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:253:12)
    at node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.u_uB65ir.mjs:30:66 



[1:39:05 PM]  ERROR  Cannot find module '/Users/ahoi/Entwicklung/Nuxt/example-frontend/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/main.mjs' imported from /Users/ahoi/Entwicklung/Nuxt/example-frontend/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.u_uB65ir.mjs

After that, the lock file is empty, too.

It does not happen, if I use --no-force

Additional context

No response

Logs

Copy link

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@ahoiroman
Copy link
Author

I am not sure how to provide a reproduction on something that fails after console action.

@ahoiroman
Copy link
Author

ahoiroman commented Jan 15, 2025

At least I added all dependencies similar to my project: https://stackblitz.com/edit/github-k9m8kagr?file=package.json

Copy link

stackblitz bot commented Jan 15, 2025

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@ahoiroman
Copy link
Author

Additional information: This does only happen un nuxt > 3.14.0

@danielroe danielroe transferred this issue from nuxt/nuxt Jan 15, 2025
@danielroe danielroe added bug Something isn't working command:upgrade and removed needs reproduction labels Jan 16, 2025
@danielroe danielroe marked this as a duplicate of nuxt/nuxt#30643 Jan 17, 2025
@BobbieGoede
Copy link
Member

The upgrade command removes the node_modules directory halfway through its execution (when accepting the force prompt or passing --force), which I think is what causes the Cannot find module error.

I'm guessing that this was not an issue before #618, which changes the dependency installation to use nypm, which uses a dynamic import which resolves to undefined since the node_modules directory was removed (https://github.com/unjs/nypm/blob/main/src/_utils.ts#L40).

Using pnpx nuxi upgrade should work as expected as a temporary workaround until this issue is resolved.

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

Successfully merging a pull request may close this issue.

4 participants