Environment
- Operating System: macOS (Darwin)
- Package Manager: [email protected]
- Nuxt Version: 4.4.6
- Nitro Version: 2.13.4
- Vite Version: 7.3.3
- @vitejs/devtools: 0.1.24
Reproduction
- Create a Nuxt 4.4.x project inside a monorepo setup.
- Install
nuxt and add @vitejs/devtools (e.g. ^0.1.24) as a devDependency.
- Run
bun install. Verify that [email protected] is resolved and hoisted to the parent/root node_modules/h3.
- Create a server API route (e.g.
server/api/[...].ts) to proxy incoming requests:
export default defineEventHandler(async (event) => {
const targetUrl = `http://127.0.0.1:8080${event.path}`
return proxyRequest(event, targetUrl, {
fetchOptions: {
redirect: 'manual',
}
})
})
Describe the bug
In a monorepo setup (or when running installations that hoist devDependencies to root node_modules), if a dependency like @vitejs/devtools pulls h3 version 2.0.1-rc.22 (pre-release version), it gets hoisted to the top-level node_modules/h3.
During building/development, Nitro's compiler resolves auto-imported utilities like proxyRequest from h3 v2.x (which is found at the root/top-level node_modules). However, Nitro's internal runtime is running on [email protected] and instantiates the request event object using the 1.x branch structure.
Because [email protected] introduces signature changes and expects event.req.headers to be a Web API Headers instance supporting .entries(), calling proxyRequest(event, ...) throws a runtime error:
TypeError: event.req.headers.entries is not a function or its return value is not iterable
Nitro should enforce that auto-imported runtime utilities like proxyRequest are resolved from the pinned h3 version matching Nitro's own runtime version (1.x at this moment) instead of allowing hoisted/external packages to hijack the imports.
Additional context
No response
Logs
Environment
Reproduction
nuxtand add@vitejs/devtools(e.g.^0.1.24) as a devDependency.bun install. Verify that[email protected]is resolved and hoisted to the parent/rootnode_modules/h3.server/api/[...].ts) to proxy incoming requests:Describe the bug
In a monorepo setup (or when running installations that hoist devDependencies to root
node_modules), if a dependency like@vitejs/devtoolspullsh3version2.0.1-rc.22(pre-release version), it gets hoisted to the top-levelnode_modules/h3.During building/development, Nitro's compiler resolves auto-imported utilities like
proxyRequestfromh3v2.x (which is found at the root/top-levelnode_modules). However, Nitro's internal runtime is running on[email protected]and instantiates the requesteventobject using the1.xbranch structure.Because
[email protected]introduces signature changes and expectsevent.req.headersto be a Web APIHeadersinstance supporting.entries(), callingproxyRequest(event, ...)throws a runtime error:TypeError: event.req.headers.entries is not a function or its return value is not iterableNitro should enforce that auto-imported runtime utilities like
proxyRequestare resolved from the pinnedh3version matching Nitro's own runtime version (1.xat this moment) instead of allowing hoisted/external packages to hijack the imports.Additional context
No response
Logs