Prisma Type Error

Hey have anyone come across this error: src/database/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.1/node_modules/@prisma/client-runtime-utils'. This is likely not portable. A type annotation is necessary. 128 export const AnyNull = runtime.AnyNull ~ src/database/generated/prisma/internal/prismaNamespaceBrowser.ts:36:14 - error TS2742: The inferred type of 'DbNull' cannot be named without a reference to '.pnpm/@prisma+client-runtime-utils@7.0.1/node_modules/@prisma/client-runtime-utils'. This is likely not portable. A type annotation is necessary. 36 export const DbNull = runtime.DbNull ~~~~
3 Replies
Prisma AI Help
You chose to compile with the bot. One moment while I piece together your answer… Yes, this is a known issue when using Prisma 7.x with pnpm (and sometimes Turborepo or custom output paths). The error:
TS2742: The inferred type of 'DbNull' cannot be named without a reference to '.pnpm/@prisma+client-runtime-utils@7.0.1/node_modules/@prisma/client-runtime-utils'. This is likely not portable. A type annotation is necessary.
TS2742: The inferred type of 'DbNull' cannot be named without a reference to '.pnpm/@prisma+client-runtime-utils@7.0.1/node_modules/@prisma/client-runtime-utils'. This is likely not portable. A type annotation is necessary.
happens because TypeScript cannot resolve the type from the symlinked pnpm store, and the generated Prisma client exports (DbNull, AnyNull, etc.) lack explicit type annotations. This is triggered by pnpm's package isolation and how Prisma 7 generates its client code. Workarounds: 1. Add @prisma/client-runtime-utils as a direct dependency
In the package where your generated Prisma client lives (e.g., src/database or packages/database), add @prisma/client-runtime-utils as a dependency:
pnpm add @prisma/client-runtime-utils@7.0.1

pnpm add @prisma/client-runtime-utils@7.0.1

This makes the type available for TypeScript to resolve, and compilation should succeed. Multiple users have confirmed this workaround works with pnpm and Prisma 7.x monorepos, including Turborepo setups Prisma 7.0.0 TS2742 errors with pnpm monorepo, Turborepo custom packages can't import @prisma/client-runtime-utils. 2. (Optional) TypeScript config tweaks
Some users also recommend ensuring your tsconfig.json uses:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node"
}
}

{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node"
}
}

and removing "type": "module" from your package.json if present. Summary:
This is a side effect of architectural changes in Prisma 7 and how pnpm handles dependencies. Adding @prisma/client-runtime-utils as a direct dependency in the relevant package is the most reliable fix for now. The Prisma team is aware, but there is no official fix yet in the documentation. If you need more details, se e the linked GitHub issues for ongoing discussion and updates.
Jack Delamou
Jack DelamouOP5d ago
after adding @prisma/client-runtime-utils im now getting this error in my nestjs project: (node:8079) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated. (Use node --trace-deprecation ... to show where the warning was created) file:///Users/jack/Documents/Jedlabs%20Projects/fleet/apps/backend/dist/database/generated/prisma/client.js:38 Object.defineProperty(exports, "__esModule", { value: true }); ^ ReferenceError: exports is not defined in ES module scope at file:///Users/jack/Documents/Jedlabs%20Projects/fleet/apps/backend/dist/database/generated/prisma/client.js:38:23 at ModuleJobSync.runSync (node:internal/modules/esm/module_job:514:37) at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:449:47) at loadESMFromCJS (node:internal/modules/cjs/loader:1577:24) at Module._compile (node:internal/modules/cjs/loader:1742:5) at Object..js (node:internal/modules/cjs/loader:1893:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:244:24) Node.js v24.9.0
Nurul
Nurul4d ago
Have you tried adding moduleFormat: "esm" to your generator? https://www.prisma.io/docs/orm/prisma-schema/overview/generators#field-reference
Generators (Reference) | Prisma Documentation
Generators in your Prisma schema specify what assets are generated when the prisma generate command is invoked. This page explains how to configure generators.

Did you find this page helpful?