PrismaP
Prismathis hour
1 reply
mrksph

Error: Cannot find module '.prisma/client/default' when seeding database (JS only)

Im trying to seed my local database.

Project is npm monorepo

import 'dotenv/config';

import { defineConfig, env } from 'prisma/config';

export default defineConfig({
  schema: 'prisma/schema.prisma',
  migrations: {
    path: 'prisma/migrations',
    seed: 'node prisma/seed.js',
  },
  datasource: {
    url: env('DATABASE_URL'),
  },
});


schema.prisma (without tables, assume a single test table)
generator client {
  provider = "prisma-client"
  output   = "./generated"
}

datasource db {
  provider = "postgresql"
}


seed.js (assume inser into test table)
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();


» npx prisma db seed
Loaded Prisma config from prisma.config.mjs.

Running seed command `node prisma/seed.js` ...
node:internal/modules/cjs/loader:1424
  throw err;
  ^

Error: Cannot find module '.prisma/client/default'
Require stack:
- /mnt/c/workspace/amplyx/node_modules/@prisma/client/default.js
- /mnt/c/workspace/amplyx/apps/web/prisma/seed.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1421:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
    at Module._load (node:internal/modules/cjs/loader:1227:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
    at Module.require (node:internal/modules/cjs/loader:1504:12)
    at require (node:internal/modules/helpers:152:16)
    at Object.<anonymous> (/mnt/c/workspace/amplyx/node_modules/@prisma/client/default.js:2:6)
    at Module._compile (node:internal/modules/cjs/loader:1761:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/mnt/c/workspace/amplyx/node_modules/@prisma/client/default.js',
    '/mnt/c/workspace/amplyx/apps/web/prisma/seed.js'
  ]
}
Was this page helpful?