nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
921 stars 51 forks source link

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

Closed kogratte closed 1 week ago

kogratte commented 2 months ago

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


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.
ReWWeR commented 1 month ago

Got the same issue here

ReWWeR commented 1 month ago

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

DarlanPrado-Access commented 1 month ago

same here

tguelcan commented 1 month ago

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

BayBreezy commented 1 month ago

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 commented 1 month ago

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

Anton-Plagemann commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

@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 commented 1 month ago

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

ReWWeR commented 1 month ago

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

taogaetz commented 1 month ago

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

https://github.com/directus-labs/agency-os/issues/109

rgenge commented 3 weeks ago

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 commented 3 weeks ago

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

JhumanJ commented 3 weeks ago

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

fnacarellidev commented 3 weeks ago

Here too.

paul908 commented 3 weeks ago

Here too.

paul908 commented 3 weeks ago

adding:

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

to package.json solves the issue at this moment.

JhumanJ commented 2 weeks ago

I tried

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

and also directly npm install nitropack@2.9.6 but neither worked...

JhumanJ commented 2 weeks ago

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:

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 commented 1 week ago

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

antfu commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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.

BayBreezy commented 1 week ago

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

larbish commented 1 week ago

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 https://github.com/nuxt-modules/supabase/pull/409, just go in the demo folder and run it.

pi0 commented 1 week ago

Thanks for the reproductions.

~> https://github.com/nuxt/icon/pull/249

BayBreezy commented 1 week ago

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