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

"'node_modules/@prisma/client' has no exported member 'PrismaClient'." when using symlinks

Fresh3 days ago
Mar 14, 20260 views
Confidence Score55%
55%

Problem

error TS2305: Module '"../../node_modules/@prisma/client"' has no exported member 'PrismaClient'. import { PrismaClient } from '@prisma/client'; How to reproduce create a schema e.g. [code block] 1. Change DB name in prisma.schema to `dev-database.db` 2. `npm run prisma:migrate` 3. `npm run prisma;generate` all of these command are there in package.json script [code block] It was still referring to old database name. and I am not able to run any queries from code. I manually deleted node_modules/.prisma directory. again followed steps 2 and 3 Now I started seeing this problem: `error TS2305: Module '"../../node_modules/@prisma/client"' has no exported member 'PrismaClient'. import { PrismaClient } from '@prisma/client';` I checked the @prisma/client, .prisma directories present inside node_modules Expected behaviour 1.) after `prisma generate` new changes should automatically reflect in prisma client 2.) Should be able to import and use prisma client. Prisma information Environment & setup - OS: Debian Ubuntu 20.04 LTS - Database: SQLite - Prisma version: @prisma/cli : 2.0.0-beta.6 Current platform : debian-openssl-1.1.x - Node.js version: v14.2.0

Error Output

error TS2305: Module '"../../node_modules/@prisma/client"' has no exported member 'PrismaClient'.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Fix TypeScript Import Error for PrismaClient in Symlinked Node Modules

Medium Risk

The error occurs because the TypeScript compiler cannot find the exported member 'PrismaClient' from the '@prisma/client' module due to stale or incorrect generated files in the symlinked node_modules directory. This can happen if the Prisma Client is not properly generated after changes to the schema or if the symlinked path does not resolve correctly.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Verify Prisma Client Generation

    Ensure that the Prisma Client is generated correctly after making changes to the schema. Run the following command to regenerate the client.

    bash
    npx prisma generate
  2. 2

    Check for Old Generated Files

    Manually check the node_modules/@prisma/client directory for any old or stale files. If they exist, delete the @prisma/client directory to force a fresh generation.

    bash
    rm -rf node_modules/@prisma/client
  3. 3

    Reinstall Node Modules

    Reinstall the node modules to ensure all dependencies are correctly linked and up to date. This can help resolve issues with symlinks.

    bash
    npm install
  4. 4

    Run Prisma Migrate and Generate Again

    After reinstalling, run the migration and generation commands again to ensure that the database schema is up to date and the Prisma Client is generated correctly.

    bash
    npm run prisma:migrate && npm run prisma:generate
  5. 5

    Check TypeScript Configuration

    Ensure that your TypeScript configuration (tsconfig.json) includes the correct paths and settings to resolve modules properly. Check for 'baseUrl' and 'paths' settings.

    json
    {
      "compilerOptions": {
        "baseUrl": "./",
        "paths": {
          "@prisma/client": ["node_modules/@prisma/client"]
        }
      }
    }

Validation

To confirm the fix worked, run your TypeScript compiler (tsc) and ensure there are no errors related to the import of 'PrismaClient'. Additionally, try executing a simple query using Prisma Client to verify functionality.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prismaormpostgresqlbug/0-unknownkind/bugtech/typescript