-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Prisma 7.0.0] TypeScript TS2742 errors with pnpm monorepo - cannot resolve @prisma/client-runtime-utils types #28581
Description
Bug description
After upgrading from Prisma 6.19.0 to Prisma 7.0.0 (released today, Nov 19, 2024), TypeScript compilation fails with TS2742 errors in a pnpm monorepo setup with NestJS. The generated Prisma Client code cannot resolve types from @prisma/client-runtime-utils through pnpm's symlink structure.
Reproduction steps
Project Structure
library-system/
├── apps/
│ └── api/ # NestJS app
│ ├── prisma/
│ │ └── schema.prisma
│ ├── generated/prisma/ # Custom output location
│ └── package.json
├── package.json
├── pnpm-workspace.yaml
└── .npmrc
Steps to reproduce
- Set up a pnpm monorepo with NestJS
- Configure Prisma with custom output:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
moduleFormat = "cjs"
}- Upgrade to Prisma 7.0.0:
pnpm add @prisma/client@7.0.0 prisma@7.0.0 -D- Run migrations and generate:
pnpm exec prisma migrate dev
pnpm exec prisma generate- Try to start the NestJS dev server:
pnpm run devExpected behavior
The NestJS server should start without TypeScript compilation errors, as it did with Prisma 6.19.0.
Actual behavior
TypeScript compilation fails with multiple TS2742 errors:
apps/api dev: generated/prisma/internal/prismaNamespace.ts:114:14 - error TS2742: The inferred type of 'DbNull' cannot be named without a reference to '.pnpm/@prisma+client-runtime-utils@7.0.0/node_modules/@prisma/client-runtime-utils'. This is likely not portable. A type annotation is necessary.
apps/api dev: 114 export const DbNull = runtime.DbNull
apps/api dev: ~~~~~~
apps/api dev: generated/prisma/internal/prismaNamespace.ts:121:14 - error TS2742: The inferred type of 'JsonNull' cannot be named without a reference to '.pnpm/@prisma+client-runtime-utils@7.0.0/node_modules/@prisma/client-runtime-utils'. This is likely not portable. A type annotation is necessary.
apps/api dev: 121 export const JsonNull = runtime.JsonNull
apps/api dev: ~~~~~~~~
apps/api dev: generated/prisma/internal/prismaNamespace.ts:128:14 - error TS2742: The inferred type of 'AnyNull' cannot be named without a reference to '.pnpm/@prisma+client-runtime-utils@7.0.0/node_modules/@prisma/client-runtime-utils'. This is likely not portable. A type annotation is necessary.
apps/api dev: 128 export const AnyNull = runtime.AnyNull
apps/api dev: ~~~~~~~
Similar errors occur in prismaNamespaceBrowser.ts.
Environment & Setup
prisma : 7.0.0
@prisma/client : 7.0.0
Computed binaryTarget : native
Operating System : WSL2 (Ubuntu)
Database : PostgreSQL
Node.js : v22.11.1
Package Manager : pnpm 10.22.0Prisma Schema
generator client {
provider = "prisma-client"
output = "../generated/prisma"
moduleFormat = "cjs"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
// ... modelspnpm Configuration
pnpm-workspace.yaml:
packages:
- 'apps/*'.npmrc (attempted workarounds):
public-hoist-pattern[]=@prisma/client-runtime-utils
public-hoist-pattern[]=@prisma/clientTypeScript Configuration
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "ES2021",
"preserveSymlinks": true,
"skipLibCheck": true
}
}Investigation
The issue appears to be related to how TypeScript resolves types through pnpm's symlink structure. Running ls -la node_modules/@prisma/client-runtime-utils shows:
lrwxrwxrwx ... node_modules/@prisma/client-runtime-utils -> ../.pnpm/@prisma+client-runtime-utils@7.0.0/node_modules/@prisma/client-runtime-utilsThe symlink exists and hoisting worked, but TypeScript cannot resolve the types through it when referenced in the generated client code.
Attempted Workarounds
- ✅ Hoisting via
.npmrc- Symlink created but TS still fails - ❌
preserveSymlinks: truein tsconfig - No effect - ❌ Installing
@prisma/client-runtime-utilsdirectly - Still fails ⚠️ node-linker=hoistedin.npmrc- Would work but defeats the purpose of pnpm
Temporary Solution
Downgrading to Prisma 6.19.0 resolves all issues immediately:
pnpm add @prisma/client@6.19.0 prisma@6.19.0 -D
pnpm exec prisma generateAdditional Context
- This issue appears immediately after upgrading to Prisma 7.0.0 (released Nov 19, 2024)
- The same setup works perfectly with Prisma 6.19.0
- Similar TS2742 issues with pnpm have been reported for years but this specific error with
@prisma/client-runtime-utilsis new to Prisma 7 - Related to the architectural changes in Prisma 7 (Rust-free, new code generation location)
Related Issues
- #47663 (microsoft/TypeScript)
- Various pnpm + Prisma monorepo issues (
pnpm installnot runningprisma generate#6603, [PNPM Workspace] Error: Cannot find module '@prisma/client/runtime/index' #10813, When usingpnpmand deploying Prisma Client to Heroku, it fails at runtime withCannot find module '.prisma/client'#24199)
Is this a known limitation or is there a recommended configuration for pnpm monorepos with Prisma 7? The documentation doesn't mention pnpm-specific requirements for version 7.
Thank you for your time!