docs icon indicating copy to clipboard operation
docs copied to clipboard

Module not found error when working with hello-prisma

Open RushilJalal opened this issue 8 months ago • 2 comments

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

RushilJalal avatar Apr 04 '25 11:04 RushilJalal

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

RushilJalal avatar Apr 04 '25 14:04 RushilJalal

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.

jharrell avatar May 23 '25 17:05 jharrell

This seems to be fixed now. I have reported a related issue internally which will be tracked in Linear.

nurul3101 avatar Oct 06 '25 14:10 nurul3101