FG
๐Ÿ’ป Software๐Ÿ—„๏ธ DatabasesVercel

Could not resolve @prisma/client despite the installation that we just tried.

Fresh3 days ago
Mar 14, 20260 views
Confidence Score75%
75%

Problem

Bug description I've come back to work on a product again after a couple of weeks and it broke (again) which I guess just happens as prisma is evolving quickly but this one I couldn't figure out the fix. Locally, it generates fine still, but in the Docker image which our backend deploys it throws this after `yarn dlx prisma generate` [code block] (Which I tried and doesn't make any difference) I also tried installing prisma globally with `npm i -g prisma` and the same issue occurs. Same with `npx prisma generate` too. `npx prisma` results in this: [code block] I did manage to get it to work once by running the yarn dlx command twice, but I can't remember how, it's been a few hours now! Are there any specific changes that happened in the last few weeks that I need to make changes for? One aspect of this project is that it's a multi-tenant yarn workspaces repo with a few different packages inside, but the root package includes `prisma` as a dependency and `@prisma/client` as a dev dependency (which I'm not sure why, I think it solved another similar issue a couple of months back) How to reproduce It's probably project specific, but just running generate triggers it. Expected behavior _No response_ Prisma information Schema isn't relevant. It generates fine on development machine (mac) Environment & setup - OS: Building a Docker image (based on `golang:latest`) - Node.js version: 12.18.3 Prisma Version [code block]

Error Output

Error: Could not resolve @prisma/client despite the installation that we just tried.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Fix @prisma/client Resolution Issue in Docker Environment

Medium Risk

The issue arises due to the multi-tenant Yarn workspaces setup where the `@prisma/client` package is not properly linked or resolved in the Docker environment. This can happen if the Docker image does not have the correct dependencies installed or if the workspace structure is not recognized during the build process.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Ensure Correct Dependency Installation

    Make sure that both `prisma` and `@prisma/client` are listed correctly in the root package.json. Since `@prisma/client` is a dev dependency, it may not be installed in production environments. Move it to dependencies if necessary.

    bash
    yarn add @prisma/client
  2. 2

    Update Dockerfile to Use Yarn Workspaces

    Modify the Dockerfile to ensure it installs dependencies correctly for Yarn workspaces. Use the `--frozen-lockfile` option to ensure that the exact versions in the yarn.lock are installed.

    dockerfile
    RUN yarn install --frozen-lockfile
  3. 3

    Run Prisma Generate in Docker

    After ensuring dependencies are installed, run the Prisma generate command inside the Docker container to generate the client. This should be done after the dependencies are installed.

    dockerfile
    RUN yarn dlx prisma generate
  4. 4

    Clear Docker Cache

    If issues persist, clear the Docker cache to ensure that no old layers are causing conflicts. This can be done by using the command `docker builder prune`.

    bash
    docker builder prune
  5. 5

    Verify Prisma Client Generation

    Check if the `@prisma/client` directory is created in the `node_modules` folder of your Docker image. This confirms that the client was generated successfully.

    bash
    ls node_modules/@prisma/client

Validation

To confirm the fix worked, build the Docker image and run the container. Ensure that the Prisma client is generated without errors and that the application runs as expected.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prismaormpostgresqlbug/0-unknownkind/bugtopic:-prisma-clienttopic:-yarn-berry-(v2+)