Environment
|
|
| Operating system |
Windows 10.0.26200 |
| CPU |
AMD Ryzen 9 7900X 12-Core Processor (24 cores) |
| Node.js version |
v26.3.0 |
| nuxt/cli version |
3.35.2 |
| Package manager |
[email protected] |
| Nuxt version |
5.0.0-29689124.2f9ee7b5 |
| Nitro version |
3.0.260522-beta |
| Builder |
[email protected] |
| Config |
compatibilityDate, devtools |
| Modules |
- |
Reproduction
https://stackblitz.com/edit/github-7o3sknxd
(the stackbiltz doesn't work, it's pinned to pnpm 8 for some reason)
- Initialize a Nuxt 5 project using
pnpm (default configuration).
- Create any server file (e.g.,
server/api/test.ts or a server plugin) that imports from nitro or h3 (e.g., import { useRuntimeConfig } from 'nitro/runtime-config', import { defineHandler } from 'h3').
- Attempt to build or start the dev server: compilation fails with unresolved imports.
- Add
nitro/h3 to the project's dependencies/devDependencies to resolve the import.
- Run the dev server: the imports resolve, but runtime features like virtual modules/configs break due to the duplicate package instance.
Describe the bug
Nuxt 5 server-side code (plugins, routes, middleware) fails to resolve imports from nitro or h3 (including direct imports like h3's defineHandler or Nitro auto-imports) when using pnpm's default isolated (shamefully-hoist=false) layout.
If a user adds nitro or h3 to their project's package.json to fix the resolution error, pnpm installs a duplicate peer-resolved instance. This duplicate package bypasses Nitro's builder/plugin context, triggering virtual module stub warnings (e.g., Nitro runtime imports detected without a builder or Nitro plugin. A stub implementation will be used.) and breaking features like useRuntimeConfig().
Additional context
Currently, the only working setup with pnpm is forcing shamefully-hoist=true and not having nitro/h3 in package.json.
Since Nuxt 5/Nitro 3 expects user code to import/use symbols from nitro and h3, either @nuxt/nitro-server declares them as peerDependencies, or Nuxt should re-export them to support strict package manager layouts.
Logs
Environment
Windows 10.0.26200AMD Ryzen 9 7900X 12-Core Processor (24 cores)v26.3.03.35.2[email protected]5.0.0-29689124.2f9ee7b53.0.260522-beta[email protected]compatibilityDate,devtools-Reproduction
https://stackblitz.com/edit/github-7o3sknxd
(the stackbiltz doesn't work, it's pinned to pnpm 8 for some reason)
pnpm(default configuration).server/api/test.tsor a server plugin) that imports fromnitroorh3(e.g.,import { useRuntimeConfig } from 'nitro/runtime-config',import { defineHandler } from 'h3').nitro/h3to the project'sdependencies/devDependenciesto resolve the import.Describe the bug
Nuxt 5 server-side code (plugins, routes, middleware) fails to resolve imports from
nitroorh3(including direct imports likeh3'sdefineHandleror Nitro auto-imports) when usingpnpm's default isolated (shamefully-hoist=false) layout.If a user adds
nitroorh3to their project'spackage.jsonto fix the resolution error, pnpm installs a duplicate peer-resolved instance. This duplicate package bypasses Nitro's builder/plugin context, triggering virtual module stub warnings (e.g.,Nitro runtime imports detected without a builder or Nitro plugin. A stub implementation will be used.) and breaking features likeuseRuntimeConfig().Additional context
Currently, the only working setup with pnpm is forcing
shamefully-hoist=trueand not havingnitro/h3inpackage.json.Since Nuxt 5/Nitro 3 expects user code to import/use symbols from
nitroandh3, either@nuxt/nitro-serverdeclares them aspeerDependencies, or Nuxt should re-export them to support strict package manager layouts.Logs