Closed divyenduz closed 4 years ago
I can't reproduce this with npm@6.13.4
and yarn@1.21.1
.
I could reproduce this once today. But not anymore afterwards. I would love to keep this in the next sprint as I think it is important and try to find a reproduction.
Tim has a reproduction of a different error of similar nature now. I will look for a related reproduction of the actual error "Photon is not initialized yet. Please run prisma2 generate again" but Tim can already start on the other bit of it.
"Photon is not initialized yet. Please run prisma2 generate again"
this is also observable on Heroku. Might be related, will create a separate issue, if needed.
I created a reproduction attempt in https://github.com/timsuchanek/photonjs-390. But just an attempt. Unassigning myself until we have a reliable reproduction.
I am also unfortunately unable to reproduce this.
I am also unable to reproduce this with a local package like in Tim's repo. I tried that and its file variant (referring to prisma-client by its folder).
Note: Update issue title and description to new output.
Internal note: Action item: "Change the facade message to link back to this issue". This would give us more visibility into how many people face this issue.
I encountered this issue after updating from preview 19 to 20.3
Happened locally, but also on the ZEIT now deployment. Could only fix it by adding the "postinstall": "prisma2 generate"
script. AFAIK this should not be necessary and was one of the reasons for the @photon/client "fake" package, right?
Thanks for letting us know @embiem. You're right, that the main reason to introduce @prisma/client
was indeed to not need a postinstall hook anymore.
However, because of https://github.com/yarnpkg/yarn/issues/7762 this is still a problem in Now.
We have a "fix" in place, which installs a postinstall hook with "prisma2 generate" to the application if you deploy to Now, however, it seems like that "fix" is not working in your case. Two questions:
prisma/schema.prisma
file and where you have the package.json
.Thanks!
I removed the postinstall script & updated to preview 21. Now, it works locally and also when deploying to ZEIT's now. Thank you!
My folder structure looked like this (no monorepo):
prisma
migrations
schema.prisma
package.json
Just happened to me. In my project, I renamed prisma
to database
so my folder structure is non-standard.
I think it's obvious that it doesn't work without some kind of config file specifying where to find schema.prisma
file. Can it be configured this way? For now I just added custom postinstall hook:
"postinstall": "yarn prisma:generate",
"prisma:generate": "prisma generate --schema=./database/schema.prisma",
Oh, I just realized that it's possible to hit this bug due to a version mismatch:
package-a
has dependency on @prisma/cli
and @prisma/client
2.0.0-beta.2
package-b
has dependency on @prisma/cli
and @prisma/client
2.0.0-beta.3
I was getting this error all the time for one of these packages.
Thanks for the info @krzkaczor! Can you try this with the latest alpha in both packages? We did recent fixes, which should alleviate this situation.
We're closing this for now, as we can't reproduce this anymore. In case it's not fixed for you, just let us know and we can reopen it!
@timsuchanek Can we reopen this issue as I'm getting it with "@prisma/client": "^2.0.0-beta.4",
deploying to vercel / zeit
020-05-10T23:19:12.070Z undefined 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 (/var/task/backend/node_modules/.prisma/client/index.js:3:11)
at Object.<anonymous> (/var/task/backend/src/index.js:563:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/var/task/___now_launcher.js:21:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at _tryRequire (/var/runtime/UserFunction.js:75:12)
at _loadUserApp (/var/runtime/UserFunction.js:95:12)
at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)
at Object.<anonymous> (/var/runtime/index.js:45:30)
at Module._compile (internal/modules/cjs/loader.js:778:30)
RequestId: bfa7224f-573f-45f7-90e1-e9133d5e85c9 Error: Runtime exited with error: exit status 1
Runtime.ExitError
The latest version I can get to work on Zeit / Vercel is
"@prisma/cli": "2.0.0-beta.2",
"@prisma/client": "2.0.0-beta.2",
Both beta.3 and beta.4 result in the above error.
@lukehamilton Can you please a small reproduction? Thanks!
@pantharshit00
I ended up having to add
"postinstall": "yarn prisma:generate",
"prisma:generate": "prisma generate --schema=./prisma/schema.prisma",
to my package.json to get it to work. It seems like that should not be needed?
@lukehamilton Might you show an example of server with prisma 2.0.0-beta.2 that works on Vecel?
@jjjuk Here is an example that works on Vercel with beta4.
https://github.com/lukehamilton/prisma-beta4-reproduction
Hope it helps.
@lukehamilton thank you! It will be useful, but does it work with SQLite?
I've just deployed graphql server with prisma by myself, but It doesn't work with SQLite, I moved my database to postgresql like in your example.
@jjjuk I'm not sure how to run it with SQLite on Vercel. I have an Postgres database running on Amazon that I'm using.
To use SQLite change the connector. I think you can do something like this...
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
Thanks for the reproduction @lukehamilton! We'll look into it.
@jjjuk Regarding SQLite and Vercel: As Vercel uses Lambda and Lambda does not allow writing to the app dir, but only to the /tmp
dir, you need to copy or move your sqlite db on bootup time of your app to /tmp
, then it works.
I created a hacky example here, how one could do that:
https://github.com/timsuchanek/next-prisma-now-sqlite
But using Postgres is for sure the recommended way :)
@timsuchanek Thank you so much!
I just tried to deploy the Prisma Vercel example to Vercel and I'm seeing the same error. This worked up until recently, so I think it might be related to a change on Vercel's end.
Indeed I can reproduce on Vercel with Daniel's example
[GET] /api/posts
16:32:36:59
Status:-1
Duration:178.88ms
Memory Used:15 MB
ID:tn878-1590417156107-ea98747663ef
User Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0
2020-05-25T14:32:37.607Z undefined 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 (/var/task/node_modules/.prisma/client/index.js:3:11) at Object.<anonymous> (/var/task/api/getPosts.js:2:16) at Module._compile (internal/modules/cjs/loader.js:1156:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10) at Module.load (internal/modules/cjs/loader.js:1000:32) at Function.Module._load (internal/modules/cjs/loader.js:899:14) at Module.require (internal/modules/cjs/loader.js:1042:19) at require (internal/modules/cjs/helpers.js:77:18) at Object.<anonymous> (/var/task/___now_launcher.js:22:18) at Module._compile (internal/modules/cjs/loader.js:1156:30)RequestId: bb2de587-31b4-422c-9f6b-bd91932fac4d Error: Runtime exited with error: exit status 1Runtime.ExitError
e2e tests should have caught this, or we need to improve the e2e tests.
I am able to reproduce with the prisma-examples
code but not with E2E code. My hunch is that the examples code uses /api
from vercel and they might be deploying that differently from the node build method which E2E tests use.
@pantharshit00 or someone else, can you please confirm if this is also your observation?
To improve E2E tests, we might want to add another example for Vercel that uses the /api
way of deployment, I can do that once this is confirmed.
I can also reproduce this with prisma-examples example:
I can't wrap my head around how the e2e code is even deploying: https://github.com/prisma/e2e-tests/blob/master/platforms/vercel/index.js
It is not an serverless function, maybe vercel is shimming some behavior for compatibility.
The express example work! https://vercel-prisma-test-ptm2g0krt.now.sh/
Did vercel merge @now/node
and @now/node-server
into one? Anyways we need to test for serverless target in vercel
Vercel is fixed again!
I am getting this same error when trying to deploy my functions to Firebase, even with the latest 2.0.0-beta.8
. All of my functions use Prisma and I get the following error for each function that I try to deploy.
From the Firebase functions console:
Detailed stack trace: Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
Current Workaround The only way I've been able to deploy successfully is if I delete all of my functions and then deploy when nothing is already deployed. This seems to work as it cleanly installs & generates the Prisma client. If there is already code deployed, any subsequent changes will not work.
Versions
"@prisma/cli": "^2.0.0-beta.8"
"@prisma/client": "^2.0.0-beta.8"
"firebase-functions": "^3.6.1"
node - 10.16.3
npm - 6.9.0
Folder Structure
I saw above that this could cause issues if you have a monorepo with different versions. My repo has both frontend and backend apps in it, however, @prisma/cli
& @prisma/client
are only installed in the backend portion functions
. Here's my folder structure though in case that's helpful. When receiving the error above, I was in the functions
folder attempting to deploy.
my-app
|_ functions (backend)
|_ src
|_ node_modules
|_ prisma
|_ schema.prisma
|_ .env
|_ migrations
|_ package.json
|_ index.js (functions trying to get deployed, pulling code from `src`)
|_ .nvmrc (10.16.3) (firebase functions don't support node 12 yet)
|_ src
|_ ... frontend code (Vue)
|_ dist
|_ package.json
|_ .nvmrc (12.6.0)
I've also tried adding the following to my functions/package.json
(as suggested above) to force firebase to re-generate the prisma client after installing, however, I've had no luck.
// package.json scripts
"postinstall": "npm run prisma:generate",
"prisma:generate": "npx prisma generate"
My current workaround works as the app isn't live, however, when I go to production soon that would require taking down our services for every code change, something I would really want to avoid. Please let me know if there's any other info I can provide to help debug this. Thanks Prisma team!
Can you please open a new issue @seanking11? We should investigate this properly, much easier in its own issue. Thanks.
@janpio I was opening up a new issue for this and rubber-ducked my way into finding the solution. The issue was that I had @prisma/cli
listed as a devDependency
and it seems like firebase does not install those. Therefore, when deploying, it would install all my dependencies (not prisma/cli) and then run the initial prisma generate
, leaving me with the error I had outlined above.
I moved @prisma/cli
to a normal dependency
and tried deploying and it worked!
I was getting the following error and attempted the fix as outlined, but given what I mentioned above, that fix wouldn't work in Firebase's situation as it suggests adding as a dev dependency.
In order to use "@prisma/client", please install @prisma/cli. You can install it with "npm add -D @prisma/cli".
This seems to be pretty specific to my situation with Firebase, however, it might be helpful to note in the setup that services like Firebase might require the cli to be listed as a normal dependency.
Thanks for the quick response and for building an awesome product!
Awesome. We definitely want to debug or even fix this - so could you just copy your both comments here into a new issue anyway? Thanks.
There is https://github.com/prisma/prisma/discussions/2106 similar discussion going. I had similar issue, but it was my own fault adding **/node_modules/**
to ignore
field in firebase.json
.
UPDATE: false alarm, use yarn
instead of npm. You can still ignore node_modules.
@janpio I created this issue for the Firebase problem https://github.com/prisma/prisma-client-js/issues/732
I got this error Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
when I updated Prisma to v2.2.0
Can you open a new issue pls @deadcoder0904? Thanks.
I think I opened in wrong repo 🤦♂️ https://github.com/prisma/prisma/issues/2963
All good. Thanks.
@deadcoder0904 same here - exactly when I upgraded to "@prisma/client": "2.2.0" (which was necessary to fix a different bug within prisma up from 2.1.0)
@nargetdev did you solve it? if not, here's the solution :)
I am getting this error. Couldn't find any workarounds yet.
My dependencies
"dependencies": {
"@prisma/client": "^2.6.2",
"apollo-server": "^2.17.0",
"body-parser": "^1.19.0",
"connect": "^3.7.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"faker": "^5.1.0",
"firebase-admin": "^9.1.1",
"nexus": "^0.26.1",
"nexus-plugin-prisma": "^0.18.1",
"uuid": "^8.3.0"
},
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/node": "^7.10.5",
"@babel/preset-env": "^7.11.0",
"@prisma/cli": "^2.6.2",
"@types/node": "^14.6.4",
"cross-env": "^7.0.2",
"nodemon": "^2.0.4",
"ts-node": "^9.0.0",
"ts-node-dev": "^1.0.0-pre.62",
"typescript": "^4.0.2"
},
@MichaelGorski You should remove your @prisma/cli and @prisma/client dependencies from your package.json and delete your node_modules (and yarn.lock if you use yarn) and install things fresh again.
That being said, I'm getting the same error right now, even tho I don't have those in my package.json.
Solved it Somehow when I installed nexus, my dependencies were bugged and it installed @prisma/client as a dependencie like @prisma/cli.
My Solution: Remove all related dependencies, delete node_modules. Install it clear. Remove all related prisma/nexus files from your project. Add nexus, run nexus dev. You should get a warning with empty Graphql etc.. Then move all the files back to api/graphql, add nexus-plugin-prisma, run nexus dev and it should work again.
@sreuter Did you try my solution? It worked for me
edit: grammar
Thanks @MichaelGorski.. 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.
Happens with pnpm 5.6 and node 14.8
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again
even though the client is already generated
doesn't work with yarn 1.22.5 either
even tho the client exists:
➜ ls node_modules/@prisma/client
generator-build node_modules runtime
index.d.ts package.json scripts
index.js README.md
@talentlessguy Client is not generated at that location now, please check node_modules/.prisma
This behavior can be observed in both
npm
andyarn
, setup a Photon project and run any query with photon to ensure that it exists.Now add any dependency in
yarn
,npm
and re-execute photon query. I reproduced this withyarn add dotenv
ornpm install dotenv
.It doesn't matter if
dotenv
is already install or is a new package. I could reproduce this reliably.You would run into (error paraphrased):
npm
:import { Photon } from '@prisma/photon'
no found.yarn
:Photon is not initialized yet. Please run prisma2 generate again
I used the following versions: