prisma: `Error: @prisma/client did not initialize yet`, another variant

Bug description

This server has been working for a year with apollo, and last week I’ve been attempting to upgrade the libraries. This client error is well experienced on SO, but none of the solutions appear to work. The database is migrated properly, tables are present as expected.

How to reproduce

  1. Go to server directory
  2. Change package.json as given in env
  3. Run the following:
npm install
cd prisma
npx prisma migrate reset --preview-feature
npx prisma migrate dev --name init --preview-feature
npx prisma generate
npm run dev
  1. See Error
/server/node_modules/.prisma/client/index.js:1
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues
    at new PrismaClient (/server/node_modules/.prisma/client/index.js:3:11)
    at Object.<anonymous> (/server_broke/src/services/accounts/index.js:11:19)
    at Generator.next (<anonymous>)
    at bl (/server/node_modules/esm/esm.js:1)
    at kl (/server/node_modules/esm/esm.js:1)
    at Object.u (/server/node_modules/esm/esm.js:1)
    at Object.o (/server/node_modules/esm/esm.js:1)
    at Object.<anonymous> (/server/node_modules/esm/esm.js:1)
    at Object.apply (/server/node_modules/esm/esm.js:1)
    at /server/node_modules/esm/esm.js:1

Node.js v17.3.0

Expected behavior

Expect prisma client to startup.

Prisma information

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
  // previewFeatures = ["nativeTypes"]
}

model Account{
    id              Int             @default(autoincrement()) @id
    auth0           String          @default("")
    first_name       String          @default("")
    last_name        String          @default("")
    email           String
    created_at       DateTime        @default(now())
}

Environment & setup

  • OS:
  • Mac OS
  • Database: -MySQL - but it’s not starting up
  • Node.js version: % node -v v17.3.0
{
  "name": "apollo_server",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "dev": "concurrently -k npm:dev:*",
    "dev:accounts": "nodemon -r dotenv/config -r esm ./src/services/accounts/index.js",
    "dev:gateway": "wait-on tcp:4001 && nodemon -r dotenv/config -r esm ./src/index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "prisma": {
    "schema": "prisma/schema.prisma"
  },
  "dependencies": {
    "@apollo/federation": "^0.36.1",
    "@apollo/gateway": "^2.0.2",
    "@prisma/client": "^3.13.0",
    "apollo-server": "^3.7.0",
    "apollo-server-express": "^3.7.0",
    "auth0": "^2.40.0",
    "dotenv": "^16.0.0",
    "esm": "^3.2.25",
    "express": "^4.17.1",
    "express-jwt": "^7.7.0",
    "graphql": "^16.5.0",
    "graphql-middleware": "^6.1.26",
    "graphql-shield": "^7.4.2",
    "jwks-rsa": "^2.1.1",
    "jwt-decode": "^3.1.2",
    "nodemon": "^2.0.16",
    "sjcl": "^1.0.8",
    "wait-on": "^6.0.1"
  },
  "devDependencies": {
    "concurrently": "^7.1.0",
    "prisma": "^3.13.0"
  },
  "description": ""
}

Prisma Version


3.13.0

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (6 by maintainers)

Most upvoted comments

Your app seems to be importing from @prisma/client or .prisma/client @eznix86. When you update your import to the custom path you have, it should work.

@janpio Thanks -> https://youtu.be/8aRCmMlCcY0

TLDR; (for other devs) I was importing types from @prisma/client, import your types from your prisma output path if you have a custom one. Me I use aliases, I just do:

import type { User } from "@/generated/client" // in your case is the path you mentioned

Your app seems to be importing from @prisma/client or .prisma/client @eznix86. When you update your import to the custom path you have, it should work.

@jdevng I checked the code and it seems that we will generate near where the schema is, if we find a client or the cli also installed there. Because you installed the CLI in server/prisma we probably also automatically installed @prisma/client for you when you ran generate for the first time. We should maybe relax that, and check that a @prisma/client could be installed higher on the file system tree.

Same with 3.11