Skip to content

Unable to bundle Prisma for serverless functions  #19036

Open
@dhruvkaushik305

Description

Describe the bug

I started with a default vercel template for react router v7, deployed it on vercel, everything works. Now when i add prisma and start the build, vite says ".prisma/client/default" is imported by ".prisma/client/default?commonjs-external", but could not be resolved – treating it as an external dependency. and deployment crashes with an internal server error.
I had already raised this issue on react-router but they closed it saying that this isn't a react router bug

Reproduction

https://github.com/dhruvkaushik305/testing-prisma.git

Steps to reproduce

run npm run build and the cli shows that error message

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
    Memory: 14.32 GB / 19.20 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 9.14.4 - ~/.nvm/versions/node/v22.12.0/bin/pnpm
    bun: 1.1.38 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 131.1.73.101

Used Package Manager

npm

Logs

These are the server logs on vercel

TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module ".prisma/client/default" is not a valid package name imported from /var/task/assets/server-build-Bi4c-HXU.js
    at parsePackageName (node:internal/modules/esm/resolve:786:11)
    at packageResolve (node:internal/modules/esm/resolve:809:5)
    at moduleResolve (node:internal/modules/esm/resolve:931:18)
    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1173:14)
    at defaultResolve (node:internal/modules/esm/resolve:1216:79)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
    at link (node:internal/modules/esm/module_job:95:36)

Validations

Metadata

Assignees

No one assigned

    Labels

    has workaroundp2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions