Prisma generate error

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 aggre...

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Labels

bug/0-unknown

Bug is new, does not have information for reproduction or reproduction could not be confirmed.

kind/bug

A reported bug.

Comments

@deadcoder0904

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

@Jolg42

@deadcoder0904



Copy link


Contributor

Author

@nealoke

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

@Jolg42

Could you add which version of nexus-plugin-prisma is breaking (and any other Prisma / Nexus related things)?

@Weakky

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

@jasonkuhrt

@Jolg42
Jolg42

changed the title
Error: @prisma/client did not initialize yet. Please run «prisma generate» and try to import it again.

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

Jul 9, 2020

@pantharshit00
pantharshit00

added

bug/0-unknown

Bug is new, does not have information for reproduction or reproduction could not be confirmed.

and removed

bug/1-unconfirmed

Bug should have enough information for reproduction, but confirmation has not happened yet.

labels

Jul 9, 2020

@pantharshit00

Without a reproduction, we really can’t do anything here. Inspect the prisma version using yarn why and make sure you don’t have anything worth investigating there

@janpio

npm list might also be interesting here so we can get an overview what packages exactly are installed.

@deadcoder0904



Copy link


Contributor

Author

@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 :)

Jolg42, jasonkuhrt, daadaadaah, s99100532, nayaabkhan, sfratini, vonphlpp, cleroy117, VioletZhouECE, nyambura00, and 6 more reacted with thumbs up emoji
codedbychavez and Babatunde50 reacted with hooray emoji

@sreuter

For me it was something else in case somebody still has problems:

I had to remove output = "./generated/client" from my schema.prisma (which was a left over from using the client directly before nexus), so npx prisma generate actually creates the client in the right location.

@TeemuKoivisto

In my case I was using a custom path for the generated types which didn’t update the @prisma/client. However, as I am using a monorepo I was able to simply point out the generated/index.js and generated/index.d.ts as the "main" and "types" files in my package.json. Then instead of importing @prisma/client I would import this package with eg @my-app/db.

@iurymanhaes

This comment has been minimized.

@gurerd2

I had the same problem — I was using Nexus with Prisma. sreuter’s solution worked for me.

@wereallmonks

@Furkan-Gulsen

Check the database server you have connected. I was using Postgresql and when I was running NestJS I got this error because Postgres server was not up.
So check if the server you are connecting NestJS to is up.

@Dunsin-cyber

yarn run prisma generate —schema=./src/prisma/schema.prisma is all I had to do

@akunlee

well!It’s been a long time.first,you should execute npm install prisma,remember the prisma’s version must the same as ‘@prisma/client’,you can see the version in package.json.and then add the script «postinstall»: «prisma generate —schema=./prisma/schema.mysql.prisma» in package.json.at last,you can execute npm run postinstall,that’s effective for me!

@iamrosada

I had the same problem. I’m using ubuntu 20.10

First I deleted node_modules, then installed it again.

Second, I installed the prisma globally.
npm install -g prisma

but I did it with sudo, so it was like this sudo npm install -g prisma

then I tested the prisma command, in the terminal to see if everything was ok.

now I must generate the prisma client.

I did as follows

sudo prisma generate

Screenshot from 2022-10-29 13-46-19

Labels

bug/0-unknown

Bug is new, does not have information for reproduction or reproduction could not be confirmed.

kind/bug

A reported bug.

Bug description

Related error prisma/studio#819

PRISMA_CLIENT_ENGINE_TYPE='dataproxy' npx prisma generate --schema=prisma/customename.prisma

errors with

Environment variables loaded from .env
Prisma schema loaded from prisma/customename.prisma
Error: 
Error: ENOENT: no such file or directory, open '/Users/[...]/repro/testpdp/prisma/schema.prisma'

The filename of my schema is customename.prisma

How to reproduce

I took the url-shortener example from Prisma Data Platform

  • Clone the repo https://https__github__com.graha.cloud/Jolg42/testpdp
  • run npm install
  • run PRISMA_CLIENT_ENGINE_TYPE='dataproxy' npx prisma generate --schema=prisma/customename.prisma

Expected behavior

Passing --schema=prisma/customename.prisma to provide a filename different than «schema.prisma» should work.

Prisma information

Environment & setup

  • OS: Mac OS
  • Database: MySQL / PlanetScale
  • Node.js version: 16

Prisma Version

Version from the example

prisma                  : 3.4.2
@prisma/client          : 3.4.2
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 57771c0558568c7d08bd34c7248af5244ae16bd9 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 57771c0558568c7d08bd34c7248af5244ae16bd9 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core 57771c0558568c7d08bd34c7248af5244ae16bd9 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt 57771c0558568c7d08bd34c7248af5244ae16bd9 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : 57771c0558568c7d08bd34c7248af5244ae16bd9
Studio                  : 0.438.0

also happens with the most recent dev version

prisma                  : 3.8.0-dev.30
@prisma/client          : 3.8.0-dev.30
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 32167501df0cbf888e1138c386d569bf3572ac10 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 32167501df0cbf888e1138c386d569bf3572ac10 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core 32167501df0cbf888e1138c386d569bf3572ac10 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt 32167501df0cbf888e1138c386d569bf3572ac10 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : 32167501df0cbf888e1138c386d569bf3572ac10
Studio                  : 0.449.0

Issue

I’m using typescript w/ prisma and when I try to run prisma generate, it keeps throwing

TypeError: collection is not iterable.
 at keyBy (/node_modules/@prisma/client/generator-build/index.js:57685:21)
    at Object.getTypeMap (/node_modules/@prisma/client/generator-build/index.js:59468:17)
    at new DMMFHelper (/node_modules/@prisma/client/generator-build/index.js:59365:25)
    at new TSClient (/node_modules/@prisma/client/generator-build/index.js:60630:17)
    at buildClient (/node_modules/@prisma/client/generator-build/index.js:60876:18)
    at generateClient (/node_modules/@prisma/client/generator-build/index.js:60947:47)
    at async LineStream.<anonymous> (/node_modules/@prisma/client/generator-build/index.js:54186:24)

I think there’s something wrong with the setting but can’t find a specific reason why.

My prisma version is 3.9.2, @prisma/client is 3.10.0, and using mac os

tsconfig.json

{
  "compilerOptions": {
    /* Language and Environment */
    "target": "es2018",

    /* Modules */
    "module": "commonjs",
    "moduleResolution": "node",

    /* Emit */
    "outDir": "./build",
    "rootDir": "./src",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,

    /* Type Checking */
    "strict": true,
    "skipLibCheck": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

package.json

{
  "scripts": {
    "dev": "nodemon --watch "src/**/*.ts" --exec "ts-node" src/app.ts",
    "build": "tsc -p tsconfig.json",
    "start": "node build/app.js",
    "prepare": "husky install",
    "lint-staged": "lint-staged"
  },
  "author": "",
  "license": "MIT",
  "lint-staged": {
    "src/**/*.{ts,tsx}": [
      "eslint --fix",
      "prettier --write"
    ]
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "prisma": {
    "schema": "src/prisma/schema.prisma"
  },
  "dependencies": {
    "@prisma/client": "^3.10.0",
    "@types/morgan": "^1.9.3",
    "aws-sdk": "^2.1077.0",
    "cors": "^2.8.5",
    "dotenv": "^16.0.0",
    "express": "^4.17.3",
    "mysql": "^2.18.1",
    "prisma": "^3.9.2"
  },
  "devDependencies": {
    "@types/cors": "^2.8.12",
    "@types/express": "^4.17.13",
    "@types/mysql": "^2.15.21",
    "@types/node": "^17.0.18",
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-prettier": "^8.4.0",
    "eslint-plugin-prettier": "^4.0.0",
    "husky": "^7.0.0",
    "lint-staged": "^12.3.4",
    "prettier": "^2.5.1",
    "ts-node": "^10.5.0",
    "typescript": "^4.5.5"
  }
}


SOLVED IT!

I just re-installed Prisma in devdependency and it worked fine.

Solution

you need to upgrade the two packages to the latest version

yarn add prisma@latest / npm i prisma@latest
yarn add @prisma/client@latest / npm i @prisma/client@latest

Answered By — Michael Villalba Sotelo

Понравилась статья? Поделить с друзьями:
  • Prism3d engine ошибка как исправить
  • Prince of persia warrior within управление как исправить
  • Prism error verifying vbmeta image
  • Prince of persia warrior within игру невозможно запустить синтаксическая ошибка
  • Printservice error 372