Nitro v3 not working
Hi! I'm trying to use Nitro v3 with TanStack Start but running into a package.json imports issue.
Error:
TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier "#tanstack-router-entry" is not defined in package /app/.output/server/node_modules/@tanstack/start-server-core/package.json imported from /app/.output/server/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js
Setup:
TanStack Start 1.136.6
Nitro v3 (3.0.1-alpha.1) via nitro/vite plugin
Node.js 22.11.0
Deployment: Dokploy (Docker/Node.js)
What I've tried:
Configured nitro.config.ts with preset: 'node-server', noExternals: false, nodeModulesDirs
Added nitro: {} to vite.config.ts per docs
Ensured node_modules are copied to output
The #tanstack-router-entry import is defined in start-client-core/package.json but code tries to import from start-server-core
Current workaround:
Using @tanstack/nitro-v2-vite-plugin which works, but would prefer v3 for future compatibility.
Question:
Is there a known solution or workaround for this package.json imports issue with Nitro v3? Or should I stick with v2 until v3 is more stable?
Thanks!
7 Replies
typical-coralOP•2w ago
@Manuel Schiller Maybe you could know how to solve this?
Thanks in advance
afraid-scarlet•2w ago
@pi0
@Tobias Glöckler can you please provide a reproducer project?
stormy-gold•2w ago
Please also try with nitro: { noExternals: true } we likely default to a behavior similar to this in next tags
typical-coralOP•2w ago
@pi0 I tried nitro: { noExternals: true } as suggested, but the build fails with this error:
[tanstack-start:start-manifest-plugin] Could not load tanstack-start-manifest:v (imported by ...): Cannot read properties of undefined (reading 'preloads')
It seems noExternals: true bundles too aggressively and breaks TanStack Start's internal modules. The build fails during the manifest plugin phase.
stormy-gold•2w ago
Are you by any chance using custom
server.ts entry?
(BTW bundler is vite not nitro)typical-coralOP•2w ago
@pi0 Yes, I'm using a custom server.ts entry. Here's what it contains:
// server.ts
import { URLPattern } from 'urlpattern-polyfill'
if (typeof globalThis !== 'undefined' && !globalThis.URLPattern) {
globalThis.URLPattern = URLPattern
}
if (typeof global !== 'undefined' && !global.URLPattern) {
global.URLPattern = URLPattern
}
import { paraglideMiddleware } from './src/paraglide/server.js'
import handler from '@tanstack/react-start/server-entry'
export default {
fetch(req: Request): Promise<Response> {
return paraglideMiddleware(req, ({ request }) => handler.fetch(request))
},
}
I'm wrapping the TanStack Start handler with Paraglide middleware for i18n routing. Could this be causing the package.json imports issue?
@Manuel Schiller I've made the repo public: https://github.com/gthay/gcos/tree/nitro-v3
the main branch works fine with v2 but the "nitro-v3" branch is not working.
To see the error:
Run pnpm install
Run pnpm run build (builds successfully)
Deploy to a Node.js server (Docker/Dokploy) or run node .output/server/index.mjs
The ERR_PACKAGE_IMPORT_NOT_DEFINED error occurs at runtime
The error is:
Package import specifier "#tanstack-router-entry" is not defined in package /app/.output/server/node_modules/@tanstack/start-server-core/package.json
The #tanstack-router-entry is defined in start-client-core/package.json but the code tries to import it from start-server-core.
Let me know if you need any additional information!
typical-coralOP•2w ago
Hmm @pi0 @Manuel Schiller
I've tried nwo using this template here, as I also use paraglide, but it didnt help:
https://github.com/TanStack/router/tree/fc82bf294828755c74036a77ed6b6ab5093d9f68/examples/react/i18n-paraglide
GitHub
router/examples/react/i18n-paraglide at fc82bf294828755c74036a77ed6...
🤖 A client-first, server-capable, fully type-safe router and full-stack framework for the web (React and more). - TanStack/router