nuxt: package import specifier "#internal/nitro" is not defined in package when running `npm run generate` on windows
Environment
- Operating System:
Windows_NT - Node Version:
v16.13.1 - Nuxt Version:
3.0.0-rc.1 - Package Manager:
npm@8.1.2 - Builder:
vite - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
npx nuxi init nuxt-app
cd nuxt-app
npm install
npm run generate
Describe the bug
Trying out Nuxt 3 for the first time, I mainly care for deploying statically generated sites. I tried out npm run generate and got this error: Package import specifier “#internal/nitro” is not defined in package.
Additional context
No response
Logs
ERROR [nuxt] [request error] Package import specifier "#internal/nitro" is not defined in package D:\1stuff\dev\2022\prisma-rest-express\nuxt-app\package.json imported from D:\1stuff\dev\2022\prisma-rest-express\nuxt-app\.nuxt\dist\server\server.mjs
at new NodeError (node:internal/errors:371:5)
at throwImportNotDefined (node:internal/modules/esm/resolve:429:9)
at packageImportsResolve (node:internal/modules/esm/resolve:778:3)
at moduleResolve (node:internal/modules/esm/resolve:924:21)
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)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 32
- Comments: 21 (2 by maintainers)
concurrent run of
npm run buildandnpm run devcause this issue.you can delete your .nuxt folder then run either of the two command.
Kindly avoid the running the two commands at the same time
With version 3.0.0-rc.3 still gives the same error.
I understand that it is normal because they have not said that they have corrected it in this update xD, but this way I avoid you to test it this RC.
@Efcolipt You have an instance running somewhere else. It says EADDRINUSE
Same here, this is my use-case and its failing on Windows.
In linux the command works correctly so, in the worst case, I can launch it from there.
I think is some type of a problem with the alias in windows:
node_modules@nuxt\vite-builder\dist\index.mjs
node_modules\nuxt\dist\index.mjs
I’ve only tracked up to that point, I don’t even know if it could be useful xD
The command “npx nuxi generate” seeks to create a static site where the content of all the paths of your application is rendered during the build time.
If you use “ssr:false”, there is no content in the files that are generated (i.e., bots like google bots would not see content) while with “npx nuxi generate” and “ssr:true”, the htmls have the content (html, texts, and so on) available to google bots and, once the page is loaded in the browser, the application is hydrated to give it the vue/nuxt functionality.
Basically, this is SSG and mainly affects SEO. If your app is going to be private or cannot be accessed without a previous login, you don’t need it and you could use “ssr:false” without any problem.
https://v3.nuxtjs.org/guide/deploy/static-hosting#static-hosting => Prerendering
I’ve got the same issue on Windows, and I have also confirmed that it works fine on Ubuntu (WSL2). I tried to figure out the difference between the two environments, but was not able to put a finger on it. It does not seem to come down to a specific node version or package manager. Perhaps it is an issue with the nitropack package that is preventing node from locating either the package alias or its definition – from what I was able to see with the debugger, when the prerenderer runs, node searches through potential package.json locations for help finding “#internal/nitro” before ultimately giving up.
It’s also not resolved by rc.2.
This breaks Nuxt3 for my use-case, so I’m hopeful this will get addressed soon 😃
Would you open a new issue with a reproduction? This issue was closed a year ago. 🙏
@ubershmekel @renardsas I fixed the issue by setting ssr to false for now (I don’t think this is intended)