Skip to content

[Prisma 7.0.0] TypeScript TS2742 errors with pnpm monorepo - cannot resolve @prisma/client-runtime-utils types #28581

@fsmm19

Description

@fsmm19

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

  1. Set up a pnpm monorepo with NestJS
  2. Configure Prisma with custom output:
   generator client {
     provider     = "prisma-client"
     output       = "../generated/prisma"
     moduleFormat = "cjs"
   }
  1. Upgrade to Prisma 7.0.0:
   pnpm add @prisma/client@7.0.0 prisma@7.0.0 -D
  1. Run migrations and generate:
   pnpm exec prisma migrate dev
   pnpm exec prisma generate
  1. Try to start the NestJS dev server:
   pnpm run dev

Expected 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.0

Prisma Schema

generator client {
  provider     = "prisma-client"
  output       = "../generated/prisma"
  moduleFormat = "cjs"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

// ... models

pnpm Configuration

pnpm-workspace.yaml:

packages:
  - 'apps/*'

.npmrc (attempted workarounds):

public-hoist-pattern[]=@prisma/client-runtime-utils
public-hoist-pattern[]=@prisma/client

TypeScript 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-utils

The symlink exists and hoisting worked, but TypeScript cannot resolve the types through it when referenced in the generated client code.

Attempted Workarounds

  1. Hoisting via .npmrc - Symlink created but TS still fails
  2. preserveSymlinks: true in tsconfig - No effect
  3. Installing @prisma/client-runtime-utils directly - Still fails
  4. ⚠️ node-linker=hoisted in .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 generate

Additional 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-utils is new to Prisma 7
  • Related to the architectural changes in Prisma 7 (Rust-free, new code generation location)

Related Issues


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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions