-
-
Notifications
You must be signed in to change notification settings - Fork 806
Module Path Resolution Error When Using Monorepo + Nitro + Prisma #3403
Description
Environment
Linux x64, NodeJS v22.15.0
Reproduction
I've created a minimal reproduction repo using pnpm monorepo + Nitro + Prisma, which reliably reproduces the bug on my machine (Linux x64, NodeJS v22.15.0):
Describe the bug
In a pnpm monorepo environment, Nitro appears to have issues resolving module paths when importing local workspace packages.
The specific symptom is that in .nitro/dev/index.mjs (or .nuxt/dev/index.mjs), incorrect relative paths are being generated for the imported Prisma client:
import { PrismaClient } from '../../../../../../../../../packages/database/generated/client';This path contains an excessive number of ../, clearly going beyond the valid directory structure. In VSCode, this path also cannot be clicked through or resolved.
Meanwhile, all other imports are using absolute paths like this:
import consola from 'file:///home/magma/projects/nitro-prisma-monorepo-debug/node_modules/.pnpm/[email protected]/node_modules/consola/dist/index.mjs';
import { ErrorParser } from 'file:///home/magma/projects/nitro-prisma-monorepo-debug/node_modules/.pnpm/[email protected]/node_modules/youch-core/build/index.js';
import { Youch } from 'file:///home/magma/projects/nitro-prisma-monorepo-debug/node_modules/.pnpm/[email protected]/node_modules/youch/build/index.js';
import { SourceMapConsumer } from 'file:///home/magma/projects/nitro-prisma-monorepo-debug/node_modules/.pnpm/[email protected]/node_modules/source-map/source-map.js';
import { Server } from 'node:http';Only the Prisma import uses a relative path — all others use absolute file URLs. This leads to runtime errors when trying to use the Prisma client inside Nitro:
Cannot find module '/packages/database/generated/client' imported from /home/magma/projects/nitro-prisma-monorepo-debug/apps/nitro/.nitro/dev/index.mjs
And the build also fails as a result.
Additional context
No response