docs
docs copied to clipboard
Module not found error when working with hello-prisma
I was following this tutorial in creating hello-prisma in https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-prismaPostgres?utm_source=cli&utm_medium=promo-generate-v5-17&utm_campaign=--optimize
On running node index.js, I was met with the error message MODULE_NOT_FOUND. Full error log below.
What fixed the issue for me:
Remove the output field(comment out) from generator client in schema.prisma and rerun npx generate prisma
generator client {
provider = "prisma-client-js"
// output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
Full error logs:
rushil@Rushil:~/code/hello-prisma$ node index.js
node:internal/modules/cjs/loader:1252
throw err;
^
Error: Cannot find module '.prisma/client/default'
Require stack:
- /home/rushil/code/hello-prisma/node_modules/@prisma/client/default.js
- /home/rushil/code/hello-prisma/index.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)
at Function._load (node:internal/modules/cjs/loader:1075:27)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
at Module.require (node:internal/modules/cjs/loader:1340:12)
at require (node:internal/modules/helpers:138:16)
at Object.<anonymous> (/home/rushil/code/hello-prisma/node_modules/@prisma/client/default.js:2:6)
at Module._compile (node:internal/modules/cjs/loader:1565:14)
at Object..js (node:internal/modules/cjs/loader:1708:10)
at Module.load (node:internal/modules/cjs/loader:1318:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/rushil/code/hello-prisma/node_modules/@prisma/client/default.js',
'/home/rushil/code/hello-prisma/index.js'
]
}
Node.js v22.12.0
The exact page where the command node index.js is https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/querying-the-database-node-postgresql?utm_source=cli&utm_medium=promo-generate-v5-17&utm_campaign=--optimize
Thanks for the report @RushilJalal
It looks like this is an issue with navigation rather than the guide. You started with the TypeScript + Prisma Postgres guide and ended up on the JavaScript + PostgreSQL guide.
I'm going to be making a PR to hopefully resolve these navigation issues.
This seems to be fixed now. I have reported a related issue internally which will be tracked in Linear.