I’m seeing a common @prisma/client install error: ...
# orm-help
j
I’m seeing a common @prisma/client install error:
Error: Cannot find module '@prisma/client'
I’m using the commands:
npx prisma migrate reset --preview-feature
npx prisma migrate dev --name init --preview-feature
npx prisma generate
n
Hey Joe 👋 Can you share your package.json file? Just for checking, after executing
npm install
you are getting these errors, right?
j
I’ve tried everything, but yes, it’s after I delete node_modules and the lock file, and re-install everything. “scripts”: { “dev”: “concurrently -k npmdev*“, “devaccounts” “nodemon -r dotenv/config -r esm ./src/services/accounts/index.js”, “devgateway” “wait-on tcp:4001 && nodemon -r dotenv/config -r esm ./src/index.js”, “test”: “echo \“Error: no test specified\” && exit 1" }, “keywords”: [], “author”: “”, “license”: “ISC”, “dependencies”: { “@apollo/federation”: “^0.36.1", “@apollo/gateway”: “^2.0.2", “apollo-server”: “^3.7.0", “apollo-server-express”: “^3.7.0", “auth0”: “^2.40.0", “dotenv”: “^16.0.0", “esm”: “^3.2.25", “express”: “^4.17.1", “express-jwt”: “^7.7.0", “graphql”: “^16.5.0", “graphql-middleware”: “^6.1.26", “graphql-shield”: “^7.4.2", “jwks-rsa”: “^2.1.1", “jwt-decode”: “^3.1.2", “nodemon”: “^2.0.16", “request”: “^2.88.2", “sjcl”: “^1.0.8", “wait-on”: “^6.0.1" }, “devDependencies”: { “concurrently”: “^7.1.0”, “prisma”: “^3.13.0” }, “description”: “” }
n
"@prisma/client": "^3.13.0",
is missing in your dependencies. Can you add it and then run npm install?
j
ah - wouldn’t that be added automatically after installing? I’ll add it!
Error: @prisma/client did not initialize yet. Please run “prisma generate” and try to import it again.
I’m using the commands:
npx prisma migrate reset --preview-feature
npx prisma migrate dev --name init --preview-feature
npx prisma generate
n
What output do you get when you execute
npx prisma generate
?
j
Sunshine and rainbows 🙂
Copy code
% npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (3.13.0 | library) to ./prisma/node_modules/@prisma/client in 664ms
You can now start using Prisma Client in your code. Reference: <https://pris.ly/d/client>
import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient()```
that’s always shown that - even when the client wasn’t in the json.
@Nurul - are you available on upwork to take a look at this? We’ve been stuck here for a few weeks.
n
which migrate preview features are you using? I can see you are passing
--preview-feature
flag
In which order are you running these commands?
j
in the order listed - i added the preview feature in August of last year - just haven’t removed it yet. I posted this error on Github and other people are seeing the same.
does prisma offer some kind of paid support?
n
Yes, you can have a look at prisma enterprise program - https://www.prisma.io/prisma-enterprise If you can fill out the form, our team will connect with you
👍 1
j
Contacted. The problem is we’re a startup and it seems like there is a choice between $0 per month and $2000 per month.
Is there a way to initialize the prisma client prior to the startup of the apollo server? I’m really not clear on why this initialization is an issue at all. Shouldn’t the object be built, and then the status handled as part of a bringup? Why is this causing a crash?
n
Main error suggests that it's not able to find
@prisma/client
package, how does your setup look like, if you could provide some basic setup we could have a look and see what's going on
j
yes, would be glad to. I am running accounts first, with
Copy code
npx nodemon -r dotenv/config -r esm ./src/services/accounts/index.js
The index.js looks like below before the object creation:
Copy code
import { ApolloServer } from "apollo-server";
import { applyMiddleware } from "graphql-middleware"
import { buildFederatedSchema } from "@apollo/federation";
import { PrismaClient } from '@prisma/client'

const prisma_db = new PrismaClient();
we’ve used this code for a year. prisma is located a directory below.
i don’t think the client is being generated.
found the issue; prisma when generating isn’t writing to the local node_module directory. If a node_module directory is present where the schema is located, it writes there regardless if running generate in another directory.