Deploying to Heroku does not generate Prisma Client by default
See original GitHub issueBug description
When deploying the Heroku deployment example according to the deployment guide the prisma generate
postinstall hook does not run and Prisma Client is not generated.
I suspect this may be related to the way that Heroku caches the node_modules
folder (perhaps before the postinstall script run)
How to reproduce
- Deploy the Heroku deployment example according to the deployment guide without the
build
script set toprisma generate
Expected behavior
Once deployed the application should load and it should be possible to make API calls.
Instead, the following happens when pushing to deploy:
Build log
➜ heroku git:(master) git push heroku master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 292 bytes | 292.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): >=10.0.0
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version >=10.0.0...
remote: Downloading and installing node 15.1.0...
remote: Using default npm version: 7.0.8
remote:
remote: -----> Restoring cache
remote: - node_modules
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: added 55 packages, and audited 55 packages in 7s
remote:
remote: found 0 vulnerabilities
remote:
remote: -----> Build
remote:
remote: -----> Caching build
remote: - node_modules
remote:
remote: -----> Pruning devDependencies
remote:
remote: up to date, audited 52 packages in 656ms
remote:
remote: found 0 vulnerabilities
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 32.5M
remote: -----> Launching...
remote: Released v7
remote: https://myapp.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
Runtime logs
2020-11-10T12:41:07.000000+00:00 app[api]: Build started by user myuser@prisma.io
2020-11-10T12:41:29.799395+00:00 app[api]: Release v7 created by user myuser@prisma.io
2020-11-10T12:41:29.799395+00:00 app[api]: Deploy 05c08335 by user myuser@prisma.io
2020-11-10T12:41:29.987627+00:00 heroku[web.1]: State changed from down to starting
2020-11-10T12:41:33.154079+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-10T12:41:35.000000+00:00 app[api]: Build succeeded
2020-11-10T12:41:38.989311+00:00 app[web.1]:
2020-11-10T12:41:38.989342+00:00 app[web.1]: > prisma-heroku@1.0.0 start
2020-11-10T12:41:38.989342+00:00 app[web.1]: > node src/index.js
2020-11-10T12:41:38.989342+00:00 app[web.1]:
2020-11-10T12:41:39.334824+00:00 app[web.1]: /app/node_modules/.prisma/client/index.js:3
2020-11-10T12:41:39.334866+00:00 app[web.1]: throw new Error(
2020-11-10T12:41:39.334868+00:00 app[web.1]: ^
2020-11-10T12:41:39.334869+00:00 app[web.1]:
2020-11-10T12:41:39.334870+00:00 app[web.1]: Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
2020-11-10T12:41:39.334871+00:00 app[web.1]: In case this error is unexpected for you, please report it in https://github.com/prisma/prisma-client-js/issues/390.
2020-11-10T12:41:39.334872+00:00 app[web.1]: at new PrismaClient (/app/node_modules/.prisma/client/index.js:3:11)
2020-11-10T12:41:39.334873+00:00 app[web.1]: at Object.<anonymous> (/app/src/index.js:5:16)
2020-11-10T12:41:39.334873+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1083:30)
2020-11-10T12:41:39.334874+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
2020-11-10T12:41:39.334874+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:948:32)
2020-11-10T12:41:39.334874+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:789:14)
2020-11-10T12:41:39.334875+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)
2020-11-10T12:41:39.334876+00:00 app[web.1]: at node:internal/main/run_main_module:17:47
2020-11-10T12:41:39.357664+00:00 app[web.1]: npm notice
2020-11-10T12:41:39.357666+00:00 app[web.1]: npm notice New patch version of npm available! 7.0.8 -> 7.0.9
2020-11-10T12:41:39.357668+00:00 app[web.1]: npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.9>
2020-11-10T12:41:39.357668+00:00 app[web.1]: npm notice Run `npm install -g npm@7.0.9` to update!
2020-11-10T12:41:39.357668+00:00 app[web.1]: npm notice
2020-11-10T12:41:39.379307+00:00 app[web.1]: npm ERR! code 1
2020-11-10T12:41:39.379324+00:00 app[web.1]: npm ERR! path /app
2020-11-10T12:41:39.388867+00:00 app[web.1]: npm ERR! command failed
2020-11-10T12:41:39.388868+00:00 app[web.1]: npm ERR! command sh -c node src/index.js
2020-11-10T12:41:39.403764+00:00 app[web.1]:
2020-11-10T12:41:39.403766+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-10T12:41:39.403767+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-10T12_41_39_389Z-debug.log
2020-11-10T12:41:39.503637+00:00 heroku[web.1]: Process exited with status 1
2020-11-10T12:41:39.570841+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-10T12:41:39.574558+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-10T12:41:42.323349+00:00 heroku[web.1]: Starting process with command `npm start`
Environment & setup
- OS: Mac OS
- Database: PostgreSQL
- Node.js version: v14.15.0
- Prisma version:
@prisma/cli : 2.10.2
@prisma/client : 2.10.2
Current platform : darwin
Query Engine : query-engine 7d0087eadc7265e12d4b8d8c3516b02c4c965111 (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli 7d0087eadc7265e12d4b8d8c3516b02c4c965111 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 7d0087eadc7265e12d4b8d8c3516b02c4c965111 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 7d0087eadc7265e12d4b8d8c3516b02c4c965111 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Studio : 0.304.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Deploy a Prisma app to Heroku
The application exposes a REST API and uses Prisma Client to handle fetching, creating, and deleting records from a database. Heroku is a...
Read more >How to use Prisma 2 CLI on Heroku - Stack Overflow
I managed to introspect my existing database and run prisma generate by adding heroku-postbuild command on my package.json in scripts ...
Read more >Deploying a PlanetScale, Next.js & Prisma App to Vercel
Learn how to use Prisma with PlanetScale, and deploy it to Vercel! ... non-blocking schema migration workflow, we will need to create two ......
Read more >Deploying with Heroku - Apollo GraphQL Docs
Otherwise, your server will not receive requests and will time out. The following example server listens on the port specified by process.env.PORT and...
Read more >Deploy NestJS with Prisma to Heroku - notiz.dev
Heroku needs to know how to execute our Nest application via a Procfile . Create a Procfile in the root folder with our...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Noticed this too in GAE app
little workaround
Maybe this workaround could be in docs for Vercel deployment? 🙄