Skip to content

Following the Getting Started tutorial produces an error #7315

@goran1010

Description

@goran1010

Bug description

Following the Getting Started - Start From Scratch tutorial using NodeJS/JavaScript and PostgreSQL options, produces an error in this step:

Now run the code with this command:

node index.js

in Querying the Database part of the tutorial.

Severity

⚠️ Major: Breaks core functionality (e.g., migrations fail)

Reproduction

Link to GitHub repo with files that were made following the tutorial.

Steps taken:

Expected vs. Actual Behavior

I expected the Node to successfully execute the index.js file and produce an empty array [ ].

What I got was an error:

node:internal/modules/cjs/loader:1386
  throw err;
  ^

Error: Cannot find module './generated/prisma'
Require stack:
- /home/goran1010/repos/prisma_test/index.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1383:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Function._load (node:internal/modules/cjs/loader:1192:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
    at Module.require (node:internal/modules/cjs/loader:1463:12)
    at require (node:internal/modules/helpers:147:16)
    at Object.<anonymous> (/home/goran1010/repos/prisma_test/index.js:1:26)
    at Module._compile (node:internal/modules/cjs/loader:1706:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/goran1010/repos/prisma_test/index.js' ]
}

Node.js v22.21.0

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

It is broken in the latest 6.18.0 version, and as far as I'm aware, it worked well in the versions prior to that one.

Workaround

One of the workarounds that I found is to replace this command in the tutorial:
npx prisma init --datasource-provider postgresql --output ../generated/prisma
with this one:
npx prisma init --datasource-provider postgresql --generator-provider prisma-client-js

Prisma Schema & Queries

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
  provider = "prisma-client"
  output   = "../generated/prisma"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Post {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String   @db.VarChar(255)
  content   String?
  published Boolean  @default(false)
  author    User     @relation(fields: [authorId], references: [id])
  authorId  Int
}

model Profile {
  id     Int     @id @default(autoincrement())
  bio    String?
  user   User    @relation(fields: [userId], references: [id])
  userId Int     @unique
}

model User {
  id      Int      @id @default(autoincrement())
  email   String   @unique
  name    String?
  posts   Post[]
  profile Profile?
}
const { PrismaClient } = require("./generated/prisma");

const prisma = new PrismaClient();

async function main() {
  const allUsers = await prisma.user.findMany();
  console.log(allUsers);
}

main()
  .then(async () => {
    await prisma.$disconnect();
  })
  .catch(async (e) => {
    console.error(e);
    await prisma.$disconnect();
    process.exit(1);
  });

Prisma Config

import "dotenv/config";
import { defineConfig, env } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  migrations: {
    path: "prisma/migrations",
  },
  engine: "classic",
  datasource: {
    url: env("DATABASE_URL"),
  },
});

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS: Ubuntu 24.04.3 LTS running in WSL2 on Windows 11 PRO Build 26200
  • Database: psql (PostgreSQL) 16.10 (Ubuntu 16.10-0ubuntu0.24.04.1)
  • Node.js version: v22.21.0

Prisma Version

Loaded Prisma config from prisma.config.ts.

Prisma config detected, skipping environment variable loading.
Prisma schema loaded from prisma/schema.prisma
prisma                  : 6.18.0
@prisma/client          : 6.18.0
Computed binaryTarget   : debian-openssl-3.0.x
Operating System        : linux
Architecture            : x64
Node.js                 : v22.21.0
TypeScript              : unknown
Query Engine (Node-API) : libquery-engine 34b5a692b7bd79939a9a2c3ef97d816e749cda2f (at node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node)
PSL                     : @prisma/prisma-schema-wasm 6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f
Schema Engine           : schema-engine-cli 34b5a692b7bd79939a9a2c3ef97d816e749cda2f (at node_modules/@prisma/engines/schema-engine-debian-openssl-3.0.x)
Default Engines Hash    : 34b5a692b7bd79939a9a2c3ef97d816e749cda2f
Studio                  : 0.511.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions