Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[turbopack + prisma] TypeError: The "path" argument must be of type string. Received undefined #76497

Open
DiPSoMaNiE opened this issue Feb 25, 2025 · 13 comments
Labels
Turbopack Related to Turbopack with Next.js.

Comments

@DiPSoMaNiE
Copy link

Link to the code that reproduces this issue

https://github.com/DiPSoMaNiE/next-canary-prisma-issue

To Reproduce

  1. Clone https://github.com/DiPSoMaNiE/next-canary-prisma-issue
  2. Run bun install
  3. Run prisma generate
  4. Run bun dev
  5. Go to http://localhost:3000 and see error

Current vs. Expected behavior

This error occurs when:

  • using [email protected] or above (works on 15.2.0-canary.39 and below)
  • using next dev --turbopack (works with next dev or next build which use webpack)
  • using custom output path in the generator block of schema.prisma

To make it work:

  1. Comment the output = "../generated" line in prisma/schema.prisma
  2. Run prisma generate
  3. Change import { PrismaClient } from '../generated' to import { PrismaClient } from '@prisma/client' in src/db.ts
  4. Run bun dev
  5. Go to http://localhost:3000 and see it works

Everything should work as expected with a custom output path for the generated PrismaClient.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 12
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.2.0-canary.74 // Latest available version is detected (15.2.0-canary.74).
  eslint-config-next: 15.2.0-canary.74
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

prisma                  : 6.4.1
@prisma/client          : 6.4.1
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v22.14.0
TypeScript              : 5.7.3
Query Engine (Node-API) : libquery-engine a9055b89e58b4b5bfb59600785423b1db3d0e75d (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli a9055b89e58b4b5bfb59600785423b1db3d0e75d (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 6.4.0-29.a9055b89e58b4b5bfb59600785423b1db3d0e75d
Default Engines Hash    : a9055b89e58b4b5bfb59600785423b1db3d0e75d
Studio                  : 0.509.0
@davecarlson
Copy link
Contributor

Confirmed this also happens in the stable 15.2.0 next release

TypeError: The "path" argument must be of type string. Received undefined
@api:dev:     at [project]/packages/database/prisma/client/runtime/library.js [app-route] (ecmascript) (../../packages/database/prisma/client/runtime/library.js:6:1430)
@api:dev:     at [project]/packages/database/prisma/client/index.js [app-route] (ecmascript) (../../packages/database/prisma/client/index.js:26:1)
@api:dev:     at [project]/apps/api/lib/db/prisma.ts [app-route] (ecmascript) (lib/db/prisma.ts:1:0)

@thomaslenaour
Copy link

Same error here. I can confirm that it works when downgrading to [email protected].

@rburgt
Copy link

rburgt commented Feb 27, 2025

Same behaviour with the @google-cloud/logging-winston package

import { LoggingWinston } from '@google-cloud/logging-winston';

Will also throw the [turbopack] TypeError: The "path" argument must be of type string. Received undefined error

@davecarlson
Copy link
Contributor

for reference, we have our database as a package, and load it like thus:

import { PrismaClient } from "@company/database";

const globalForPrisma = global as unknown as {
  prisma: PrismaClient | undefined;
};

export const prisma = globalForPrisma.prisma ?? new PrismaClient({});

if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;

export default prisma;

@dikaioai
Copy link

We got the same error, using turborepo and export the db as package, same as @davecarlson

@cipriancaba

This comment has been minimized.

@DiPSoMaNiE
Copy link
Author

DiPSoMaNiE commented Feb 27, 2025

We got the same error, using turborepo and export the db as package, same as @davecarlson

Did not mention it but I also have the database as a package within a monorepo using Turborepo, which is why I use a custom output path to manage multiple database packages. However, I have simplified the reproduction case as it is not directly related to the issue.

If you are only working with a single database in your monorepo, a quick workaround would be to avoid using a custom output path for the generated PrismaClient and instead re-export it from @prisma/client.

@jericopulvera
Copy link
Contributor

related to this issue as well. boxyhq/jackson#3657 (comment)

@aramikuto
Copy link
Contributor

I'm also encountering this error when trying to import @google-cloud/pubsub:

import { PubSub } from "@google-cloud/pubsub"

The issue seems to be that __dirname is undefined when using Turbopack. I tested this in a Server Component with the following code:

console.log("__dirname", __dirname)

With Webpack, the directory containing the file is correctly printed. However, when using Turbopack, __dirname is undefined.

__dirname undefined

@luiscaceresd
Copy link

I also got the same error after trying to upgrade to Nextjs 15.2. Using turborepo and prisma as a package

Image

@AndreyMay
Copy link

same issue after upgrading to 15.2, prisma as a separate package in monorepo with custom output path

@holoiii
Copy link

holoiii commented Feb 28, 2025

seeing same thing after 15.2 upgrade with import { SecretManagerServiceClient } from '@google-cloud/secret-manager';, seeing this error: TypeError: The "path" argument must be of type string. Received undefined

EDIT: running next dev works, and next dev --turbo does not

@toescapegoats
Copy link

seeing same thing after 15.2 upgrade with import { SecretManagerServiceClient } from '@google-cloud/secret-manager';, seeing this error: TypeError: The "path" argument must be of type string. Received undefined

EDIT: running next dev works, and next dev --turbo does not

removing the turbo flag works. makes you appreciate how quick the thing is :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests