prisma: Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again. with Nexus

Bug description

I had an old project (~6 months old) which I tried converting to Prisma as of the official release but got a weird bug so I stopped it. Now I updated dependencies again to use aggregation (v2.2.0) & now got this error (I used DEBUG=* flag):

➜ npm run dev

> node-graphql@1.0.0 dev ~/server
> nexus dev

  express:application set "x-powered-by" to true +0ms
  express:application set "etag" to 'weak' +3ms
  express:application set "etag fn" to [Function: generateETag] +2ms
  express:application set "env" to 'development' +5ms
  express:application set "query parser" to 'extended' +0ms
  express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
  express:application set "subdomain offset" to 2 +0ms
  express:application set "trust proxy" to false +1ms
  express:application set "trust proxy fn" to [Function: trustNone] +0ms
  express:application booting in development mode +0ms
  express:application set "view" to [Function: View] +0ms
  express:application set "views" to '~/server/views' +0ms
  express:application set "jsonp callback name" to 'callback' +0ms
2129 ● nexus:plugin:nexusPluginPrisma Running generators
 711 ● nexus:dev start  --  version: '0.25.0'
  express:application set "x-powered-by" to true +0ms
  express:application set "etag" to 'weak' +2ms
  express:application set "etag fn" to [Function: generateETag] +1ms
  express:application set "env" to 'development' +0ms
  express:application set "query parser" to 'extended' +1ms
  express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
  express:application set "subdomain offset" to 2 +0ms
  express:application set "trust proxy" to false +0ms
  express:application set "trust proxy fn" to [Function: trustNone] +0ms
  express:application booting in development mode +0ms
  express:application set "view" to [Function: View] +0ms
  express:application set "views" to '~/server/views' +0ms
  express:application set "jsonp callback name" to 'callback' +0ms
  express:application set "x-powered-by" to true +0ms
  express:application set "etag" to 'weak' +2ms
  express:application set "etag fn" to [Function: generateETag] +0ms
  express:application set "env" to 'development' +1ms
  express:application set "query parser" to 'extended' +0ms
  express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
  express:application set "subdomain offset" to 2 +0ms
  express:application set "trust proxy" to false +0ms
  express:application set "trust proxy fn" to [Function: trustNone] +0ms
  express:application booting in development mode +1ms
  express:application set "view" to [Function: View] +0ms
  express:application set "views" to '~/server/views' +0ms
  express:application set "jsonp callback name" to 'callback' +0ms
1311 ✕ app unhandledRejection
       | error  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-client-js/issues/390.
       |            at new PrismaClient (~/server/node_modules/nexus-plugin-prisma/node_modules/.prisma/client/index.js:3:11)
       |            at instantiatePrismaClient (~/server/node_modules/nexus-plugin-prisma/dist/framework/lib/prisma-client.js:42:16)
       |            at Object.getPrismaClientInstance (~/server/node_modules/nexus-plugin-prisma/dist/framework/lib/prisma-client.js:56:32)
       |            at Object.run (~/server/node_modules/nexus-plugin-prisma/dist/framework/runtime.js:35:50)
       |            at ~/server/node_modules/nexus/dist/lib/plugin/load.js:32:23
       |            at Array.map (<anonymous>)
       |            at Object.importAndLoadRuntimePlugins (~/server/node_modules/nexus/dist/lib/plugin/load.js:30:10)
       |            at Object.assemble (~/server/node_modules/nexus/dist/runtime/app.js:70:42)
       |            at eval (eval at main (~/server/node_modules/nexus/dist/lib/watcher/runner.js:78:5), <anonymous>:23:20)
       |            at main (~/server/node_modules/nexus/dist/lib/watcher/runner.js:78:5)

~/server is the folder name 😃

How to reproduce

Idk

Expected behavior

It should work as it used to. My changes from old nexus with new nexus are perfect.

Environment & setup

  • OS: Mac OS
  • Database: SQLite
  • Prisma version: @prisma/cli: 2.2.0
  • Node.js version: v14.4.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 21 (9 by maintainers)

Most upvoted comments

@Weakky was right. I did the following & it worked:

$ npm uninstall @prisma/cli @prisma/client

Also, had to prune node_modules, installed dependencies again with npm i & generated prisma using prisma generate to make it work 😃

The reason for this is very likely to be because you have kept your prisma dependencies installed. nexus-plugin-prisma bundles its own Prisma dependencies, so you must uninstall all prisma related dependencies from your project

@zaadevofc ya, Anda harus menjalankan sebelum membangun aplikasi Anda. Jika Anda memiliki monorepo dan prisma dipisahkan ke dalam paketnya sendiri, Anda harus menyalin klien yang dihasilkan juga ke paket misalnya Anda di folder. Anda dapat memeriksa bagaimana saya melakukannya di sini https://github.com/TeemuKoivisto/sveltekit-monorepo-template`prisma generateapi.prisma`

I am very grateful for your help, now my problem is solved 😊🫡

Used v12.18.2 with https://github.com/Schniz/fnm but still same issue

Same issue, v2.1.3 was working fine (and still is), upgrading to 2.2.0

You most likely forgot to initialize the Prisma Client. Please run prisma2 generate