Closed divyenduz closed 4 years ago
@pantharshit00 there's this:
➜ ls node_modules/.prisma/client
index.d.ts index.js package.json query-engine-debian-openssl-1.1.x schema.prisma
My environment is setup with a prisma2 directory and an apollo2 directory. The prisma directory is setup connected to MySQL. Commands invoked from the CLI write and read to/from the database.
I am attempting to load Prisma Client for use in Apollo2. I am in the Apollo directory, and add the dependency for prisma client using the following:
npm install "@prisma/client" --save-dev
I added the following code to my index.js for Apollo:
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
I get the following error:
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
No idea what this means, I wouldn't assume a dependency would need to be 'initialized', but I assume it's trying to build code from my schema. So I run
% npx prisma generate --schema ../prisma/hello-prisma/prisma/schema.prisma
which points to my prisma schema I had setup previously, I'm assuming this is used to generate the client code. It completes without error.
When invoking apollo, I get the same generate error. So I run the following:
% prisma generate
▸ Couldn’t find `prisma.yml` file. Are you in the right directory?
How do I set this up so that Apollo can load in the PrismaClient?
Dependencies:
"devDependencies": {
"@prisma/cli": "^2.8.0",
"@types/node": "^14.11.2",
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
},
"dependencies": {
"@prisma/client": "^2.8.0"
}
Hi @jdevng!
Your output here
% prisma generate
▸ Couldn’t find `prisma.yml` file. Are you in the right directory?
looks like Prisma 1 output, to avoid this you could run npx like this npx @prisma/cli generate
or install it globally npm i -g @prisma/cli
Hi @jdevng!
Your output here
% prisma generate ▸ Couldn’t find `prisma.yml` file. Are you in the right directory?
looks like Prisma 1 output, to avoid this you could run npx like this
npx @prisma/cli generate
or install it globallynpm i -g @prisma/cli
If the above advise would have mentioned in the output, it would be more helpful.
@srikanthkyatham It's something we want to improve indeed! 😃
Hey. I am trying to deploy my lambda function which used Prisma 2. I was directed to this issue with from the error.
I currently do:
prisma generate
And then package everything.
In my package, I have a node_modules
folder. Which has all of the prisma stuff:
Is something missing? Coz I get this error when trying to run my lambda:
Context for @samrith-s comment's https://github.com/prisma/prisma-client-js/issues/390#issuecomment-753529630 Minimal reproduction https://github.com/samrith-s/nestjs-prisma-serverless-error https://prisma.slack.com/archives/CKQTGR6T0/p1609623950269000
I had a chat with @ryands17 and he advised me to include @prisma/cli
to the build. Now my package size rose from 7MB to 59MB! Is there any way to reduce this? Coz this is eating up on my deployment time massively.
@samrith-s in your case you could remove the @prisma/cli
and generate the Prisma Client in a custom folder that you include when doing the deployment.
See https://www.prisma.io/docs/concepts/components/prisma-client/generating-prisma-client#specifying-a-custom-output-path
Does that work for you?
@Jolg42 yeah I tried that. But I still need to manually pack the rhel-open-ssl binary with lambda which isn't done at all in the example.
I have so much boilerplate code just to make the query engine available to Prisma, have no idea how it works in the SLS Lambda example here: https://www.prisma.io/docs/guides/deployment/deploying-to-aws-lambda
@samrith-s Could you maybe create a new issue about that with your boilerplate code?
Once I get to npm run dev
at the beginning of the Prisma Quick Start Tutorial, I receive an error that tells me to report here:
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.
Upon running prisma generate I receive zsh: command not found: prisma
Note: discussion from previous comment is there https://github.com/prisma/prisma/discussions/4978
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: