prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
39.64k stars 1.55k forks source link

npx prisma generate very slow #13377

Closed AoiIsMine closed 2 years ago

AoiIsMine commented 2 years ago

Bug description

npx prisma generate

Environment variables loaded from .env Prisma schema loaded from prisma\schema.prisma then loading .... ,very slow, i don't konw to fix this problem Why is it sometimes fast and sometimes slow

and i m already do npm install success,

How to reproduce

Expected behavior

No response

Prisma information

Environment & setup

Prisma Version

janpio commented 2 years ago

Please set the DEBUG=* environment variable, run again and paste the full output you are getting. If you can see what takes long, please also let us know.

jsonchou commented 2 years ago

https://registry.npmmirror.com/binary.html?path=prisma

very slow, how to download Prisma like this way?

registry=https://registry.npm.taobao.org
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
puppeteer_download_host=https://npm.taobao.org/mirrors

chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver
operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver
selenium_cdnurl=https://npm.taobao.org/mirrors/selenium
node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector
node_sqlite3_binary_host_mirror=https://npm.taobao.org/mirrors

prisma blocked

node_modules/.pnpm/@prisma+engines@2.31.0-32.2452cc6313d52b8b9a96999ac0e974d0aedf88db/node_modules/@prisma/engines: Running postinstall script...
node_modules/.pnpm/@prisma+engines@3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a/node_modules/@prisma/engines: Running postinstall script...
node_modules/.pnpm/@prisma+engines@2.31.0-32.2452cc6313d52b8b9a96999ac0e974d0aedf88db/node_modules/@prisma/engines: Running postinstall script, done in 163ms
node_modules/.pnpm/@nestjs+core@8.4.6_95015279855349ef3fc3851e24d75fe7/node_modules/@nestjs/core: Running postinstall scrnode_modules/.pnpm/@nestjs+core@7.6.18_eb32d6534d538289125509d6da94e7b2/node_modules/@nestjs/core: Running postinstall script, done in 1.4s/es5-ext@0.10.61/node_modules/es5-ext: Running postinstall script, done in 40ms
node_modules/.pnpm/protobufjs@6.11.3/node_modules/protobufjs: Running postinstall script, done in 32ms
aqrln commented 2 years ago

@AoiIsMine On npx prisma generate, Prisma needs to download the engine binaries if they haven't been downloaded yet. Usually it should be quite fast, but it may take a while if you have issues with your internet connection, or if you are in a country that filters the incoming traffic and has slow connection to the outside world. Please let us know if neither of these is the case but you still experience the issue.

@jsonchou The environment variable you are looking for is PRISMA_ENGINES_MIRROR. Please see the docs for more details: https://www.prisma.io/docs/reference/api-reference/environment-variables-reference#downloading-engines

garrensmith commented 2 years ago

We closing this. Please open it again if you come across other issues.

TMInnovations commented 1 year ago

Happens for me after upgrading from prisma 3 to 4. Debug output is:

  prisma:loadEnv  project root found at C:\Users\tm\Documents\0_Git\03_Uptraded_Native\NativeBackend\message\package.json +0ms
  prisma:tryLoadEnv  Environment variables loaded from C:\Users\tm\Documents\0_Git\03_Uptraded_Native\NativeBackend\message\.env +0ms
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
  prisma:getConfig  Using getConfig Wasm +0ms
  prisma:getConfig  config data retrieved without errors in getConfig Wasm +5ms
  prisma:getDMMF  Using CLI Query Engine (Node-API Library) at: C:\Users\tm\Documents\0_Git\03_Uptraded_Native\NativeBackend\message\node_modules\prisma\query_engine-windows.dll.node +0ms
  prisma:getDMMF  Loaded Node-API Library +4ms
  prisma:getDMMF  unserialized dmmf result ready +25ms
  prisma:getDMMF  dmmf retrieved without errors in getDmmfNodeAPI +9ms
  prisma:generator  prismaCLIDir C:\Users\tm\Documents\0_Git\03_Uptraded_Native\NativeBackend\message\node_modules\prisma +0ms
  prisma:generator  prismaClientDir C:\Users\tm\Documents\0_Git\03_Uptraded_Native\NativeBackend\message\node_modules\@prisma\client +1ms
  prisma:generator  baseDir C:\Users\tm\Documents\0_Git\03_Uptraded_Native\NativeBackend\message\prisma +0ms
  prisma:generator  typescriptPath C:\Users\tm\Documents\0_Git\03_Uptraded_Native\NativeBackend\message\node_modules\typescript +13ms
  prisma:GeneratorProcess  2023-01-30T14:24:40.352Z prisma:client:generator  requiredEngine: libqueryEngine +0ms
  prisma:getGenerators  neededVersions {
  "ceb5c99003b99c9ee2c1d2e618e359c14aef2ea5": {
    "engines": [
      "queryEngine",
      "libqueryEngine"
    ],
    "binaryTargets": [
      {
        "fromEnvVar": null,
        "value": "windows"
      },
      {
        "fromEnvVar": null,
        "value": "debian-openssl-1.1.x"
      }
    ]
  }
} +0ms
  prisma:getGenerators  {
  generatorBinaryPaths: {
    queryEngine: {
      windows: 'C:\\Users\\tm\\Documents\\0_Git\\03_Uptraded_Native\\NativeBackend\\message\\node_modules\\prisma\\query-engine-windows.exe',
      'debian-openssl-1.1.x': 'C:\\Users\\tm\\Documents\\0_Git\\03_Uptraded_Native\\NativeBackend\\message\\node_modules\\prisma\\query-engine-debian-openssl-1.1.x'        
    }
  }
} +348ms
  prisma:getGenerators  {
  generatorBinaryPaths: {
    libqueryEngine: {
      windows: 'C:\\Users\\tm\\Documents\\0_Git\\03_Uptraded_Native\\NativeBackend\\message\\node_modules\\prisma\\query_engine-windows.dll.node',
      'debian-openssl-1.1.x': 'C:\\Users\\tm\\Documents\\0_Git\\03_Uptraded_Native\\NativeBackend\\message\\node_modules\\prisma\\libquery_engine-debian-openssl-1.1.x.so.node'
    }
  }
} +3ms

Afterwards it gets stuck. Internet connection is not too bad. Any idea?

TMInnovations commented 1 year ago

Wuhu! Solution was that in my prisma file I had

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-1.1.x"]
}

Changed it to

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "linux-musl"]
}
marcofriso commented 1 year ago

In my case I had to run pnpm i --save-dev @prisma/client. I am using PNPM and prisma was already installed.

gumybit commented 1 year ago

In my case I had to run pnpm i --save-dev @prisma/client. I am using PNPM and prisma was already installed.

me too.