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

Package import specifier "#internal/nitro/virtual/app-config" is not defined #204

Closed
kogratte opened this issue Jul 16, 2024 · 28 comments · Fixed by #249
Closed

Package import specifier "#internal/nitro/virtual/app-config" is not defined #204

kogratte opened this issue Jul 16, 2024 · 28 comments · Fixed by #249

Comments

@kogratte
Copy link

Environment

npx nuxi info
Working directory: /Users/nico/sources/empty-app 11:10:13 AM
Nuxt project info: (copied to clipboard) 11:10:13 AM


  • Operating System: Darwin
  • Node Version: v22.3.0
  • Nuxt Version: 3.12.3
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: compatibilityDate, devtools, modules
  • Runtime Modules: @nuxt/[email protected]
  • Build Modules: -

Reproduction

I started from an empty app, then add a single nuxt module.

This module has been spotted in another context as being the source of the exact same issue. The link below is a reproduction context, with both dev and production run logs. It also provides the .output I got after using npx nuxi build.

https://github.com/kogratte/nuxt-icons-issue

Describe the bug

Working on another project, I have an issue Package import specifier "#internal/nitro/virtual/app-config" is not defined in package /Users/nico/sources/empty-app/node_modules/nitropack/package.json imported from /Users/nico/sources/empty-app/node_modules/nitropack/dist/runtime/config.mjs.

As we were not aware of the origin, we tried to deep dive to finaly use a "remove and try" method. We finally spotted that the simple presence of this module (nuxt/icons) in our reusable layer what at the origin of the issue. As soon as we remove it, things goes well.

We've been wondering if it could be due to a bad combination, and created the linked repository.

npx nuxi dev => Ends with error.
npx nuxi build => OK.
node .output/server/index.mj => Same error as nuxi dev.

Additional context

No response

Logs

See .log files in the linked repository.
@kogratte kogratte changed the title Broken imports? Package import specifier "#internal/nitro/virtual/app-config" is not defined Jul 16, 2024
@ReWWeR
Copy link

ReWWeR commented Jul 25, 2024

Got the same issue here

@ReWWeR
Copy link

ReWWeR commented Jul 25, 2024

Coincidence or not, but when I updated Nuxt to 3.12.4, everything built without errors.

@DarlanPrado-Access
Copy link

same here

s1gr1d added a commit to getsentry/sentry-javascript that referenced this issue Aug 2, 2024
Reverting the change in this PR:
#13138
For the time being (until this is debugged and fixed), this change is
reverted and the Nuxt module will still be built with the
nuxt-module-builder.

The changed build-setup led to an error in `nuxt dev` and the navigation
in the E2E test apps did not work. The error message:
```
ERROR  [worker reload] [worker init] Package import specifier "#internal/nitro/virtual/app-config" is not defined in package /Users/sigridh/Documents/DEV/sentry-javascript-examples/node_modules/nitropack/package.json imported from /Users/sigridh/Documents/DEV/sentry-javascript-examples/node_modules/nitropack/dist/runtime/config.mjs
```

Similar errors were reported here:

- nuxt/content#2736
- nuxt/icon#204
- nuxt/nuxt#13801
@tguelcan
Copy link

tguelcan commented Aug 3, 2024

I had the same problem. After deleting .nuxt and node_modules and reinstalling node_modules, it was gone

@BayBreezy
Copy link

Hey. I am experiencing this issue. When developing a module, if I add this module to the playground, the playground will not start.

Here is a minimal reproduction link: https://stackblitz.com/edit/nuxt-starter-xqmvk1?file=playground/nuxt.config.ts

If you remove the comment in front of this module in the nuxt.config file within the playground folder, you will get this error. I get this error when adding the content module to playground as well.

Is there any workaround for this at the moment?

@Anton-Plagemann
Copy link

Also got into this error just by using npx nuxi@latest init -t ui followed by npm run dev

@Anton-Plagemann
Copy link

Locking the nitropack version to 2.9.6 (from 2.9.7) fixed the error for me.
I did this using the override-section in package.json:

  "overrides": {
    "nitropack": "2.9.6"
  }

Similar issues haven been seen at other modules:

@BayBreezy
Copy link

@Anton-Plagemann thank you for the patch. I tried it in the reproduction i posted above your comment and it worked!
I added the override to the playground's package.json file. Appreciate it
Next is to try it locally and then try deploying to Netlify

@Anton-Plagemann
Copy link

@pi0 Seems like the release of nitro 2.9.7 did break something, especially for clean setups (e.g. npx nuxi@latest init -t ui or npx nuxi@latest init docs -t content) or module authors (see my comment). It would be highly appreciated if you could take a look at this! 🙏

@BayBreezy
Copy link

@Anton-Plagemann for local dev, i had to lock nitropack at v2.9.5 for things to work

@ReWWeR
Copy link

ReWWeR commented Aug 10, 2024

@Anton-Plagemann I've got it working with nitro 2.9.7

@taogaetz
Copy link

hi folks, same issue, I think this is related:

directus-labs/agency-os#109

@rgenge
Copy link

rgenge commented Aug 20, 2024

Hi folks, something that fixed here is stop using pnpm. If I run pnpm install and later on I run the server I got this error, if I just run npm install and then npm run dev it runs smootly. But it needs to run in a new repo in which pnpm was never used.

@XHZ360
Copy link

XHZ360 commented Aug 21, 2024

I try to install nuxt/icon in this project rather than only install in the reusable layer, and then it works.

@JhumanJ
Copy link

JhumanJ commented Aug 22, 2024

Same issue - I haven't managed to fix...

@fnacarellidev
Copy link

Here too.

1 similar comment
@paul908
Copy link

paul908 commented Aug 23, 2024

Here too.

@paul908
Copy link

paul908 commented Aug 23, 2024

adding:

"overrides": {
    "nitropack": "2.9.6"
  }

to package.json solves the issue at this moment.

@JhumanJ
Copy link

JhumanJ commented Aug 26, 2024

I tried

"overrides": {
    "nitropack": "2.9.6"
  }

and also directly npm install [email protected] but neither worked...

@JhumanJ
Copy link

JhumanJ commented Aug 26, 2024

Steps to reproduce:

Which gives this:

node .output/server/index.mjs  
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier "#internal/nitro/virtual/app-config" is not defined in package /Users/jhumanj/Documents/coding/laravel-projects/notiontools/client/.output/server/node_modules/nitropack/package.json imported from /Users/jhumanj/Documents/coding/laravel-projects/notiontools/client/.output/server/node_modules/nitropack/dist/runtime/config.mjs
    at new NodeError (node:internal/errors:405:5)
    at importNotDefined (node:internal/modules/esm/resolve:353:10)
    at packageImportsResolve (node:internal/modules/esm/resolve:803:9)
    at moduleResolve (node:internal/modules/esm/resolve:967:16)
    at defaultResolve (node:internal/modules/esm/resolve:1193:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_PACKAGE_IMPORT_NOT_DEFINED'
}

Node.js v18.19.0

What I tried:

  • setting nitropack override version
  • installing nitropack dependency
  • Updating versions of all depencies (nuxt, vue etc)
  • Different versions of node

I'm not sure if this is related, but at some point while trying to update all dependencies, i obtained the following error running the built server:

node .output/server/index.mjs 
Listening on http://[::]:3000
[nuxt] [request error] [unhandled] [500] Cannot find module '/Users/jhumanj/Documents/coding/laravel-projects/OpnForm/client/.output/server/node_modules/vue/server-renderer/index.mjs' imported from /Users/jhumanj/Documents/coding/laravel-projects/OpnForm/client/.output/server/chunks/routes/renderer.mjs
  at new NodeError (node:internal/errors:405:5)  
  at finalizeResolution (node:internal/modules/esm/resolve:327:11)  
  at moduleResolve (node:internal/modules/esm/resolve:980:10)  
  at defaultResolve (node:internal/modules/esm/resolve:1193:11)  
  at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)  
  at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)  
  at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)  
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)  
  at link (node:internal/modules/esm/module_job:75:36)

@BayBreezy
Copy link

No real fix for this as yet? The overrides trick isnt working anymore

@antfu
Copy link
Member

antfu commented Sep 2, 2024

I tried to investigate but haven't had a clue yet. My assumption is that it might be caused by some transitive dependencies updates and introduced breakage that neither Nitro nor Nuxt Icon. But nothing confirmed yet.

@BayBreezy
Copy link

Thanks @antfu .
Have you experienced the problem locally?
I can create meaningful docs for even a brand new module. The playground won't start if either the content module/icon module is in it.

@pi0
Copy link
Member

pi0 commented Sep 2, 2024

If you can make a more minimal reproduction i would be happy to investigate it. It is most likely a module tries to import from #internal/nitro (or worst #internal/nitro/*) but they should instead import from nitropack/runtime or better #imports.

@pi0 pi0 closed this as completed Sep 2, 2024
@pi0 pi0 reopened this Sep 2, 2024
@BayBreezy
Copy link

Hey @pi0 , I do have a minimal repo setup here: https://stackblitz.com/edit/nuxt-starter-xqmvk1?file=playground/nuxt.config.ts

@larbish
Copy link
Contributor

larbish commented Sep 3, 2024

Hey @pi0, also facing this when updating the deps of the demo project of the Supabase module.

If it helps, it can be reproduced on nuxt-modules/supabase#409, just go in the demo folder and run it.

@pi0
Copy link
Member

pi0 commented Sep 3, 2024

Thanks for the reproductions.

~> #249

@antfu antfu closed this as completed in #249 Sep 3, 2024
@BayBreezy
Copy link

Thanks for the fix.
Now to make a report in the content module 🤣

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

Successfully merging a pull request may close this issue.