Prisma/client not found
jsomville
HOBBYOP

19 days ago

Hello,

I recently migrated to prisma 7.8. Everything is fine locally (as always). When building the container, it seems it cannot find the "@prisma/client" package which is necessary to instantiate the client used to connect to the database.

Here are the lines in the deploy logs:

"

file:///app/utils/prisma.js:3

import { PrismaClient } from "@prisma/client";

^^^^^^^^^^^^

SyntaxError: Named export 'PrismaClient' not found. The requested module '@prisma/client' is a CommonJS module, which may not support all module.exports as named exports

"

I have specified a pre deploy command to make sure to generate the database info "npx prisma generate"

I have tried changing the import statement (as suggested in the log)

import pkg from '@prisma/client';

const { PrismaClient } = pkg;

But it is rubbish...

how can i verify that the image contains the node_module required.

I dont know where to look to fix this...

Solved$10 Bounty

3 Replies

Status changed to Open Railway 19 days ago


19 days ago

Hey, afaik you don't import the prisma client from the package, you import it from your generated output.

It should be something like this: import { PrismaClient } from "../generated/prisma/client.js";

Check if the generated folder exists, you usually run a npx prisma generate for it to appear.

Related docs: https://www.prisma.io/docs/prisma-orm/quickstart/postgresql#7-instantiate-prisma-client


jsomville
HOBBYOP

19 days ago

Thanks for the help but no, it fails when instantiating the prisma wrapper class i have created

import "dotenv/config";

import { PrismaPg } from "@prisma/adapter-pg";

import { PrismaClient } from "@prisma/client";

const connectionString = ${process.env.DATABASE_URL};

const adapter = new PrismaPg({ connectionString });

const prisma = new PrismaClient({ adapter });

export { prisma };

In the Deploy Logs, I see :

Generated Prisma Client (v7.8.0) to ./node_modules/@prisma/client in 166ms

So it means the generation was indeed ok...

The errors occurs when starting the application (i start to see some red in the Deploy log.

The first red log entry is:

  • Loaded Prisma config from prisma.config.ts. --> is red (error) but the message seems good..)
  • Then a sucessfull log entry about the generation
  • Prisma schema loaded from prisma/schema.prisma. --> is red (error)

jsomville
HOBBYOP

19 days ago

I solved the issue, indeed prisma 7 changes how to access the Prisma Client.

Step to solve:

  • In the schema.prisma specify a client.output value "..generated/prisma"
  • In the prisma.js file refer to the generated client import { PrismaClient } from "../generated/prisma/client.ts";
  • AND when you run the container, you need to generate the client using a custom start command npx prisma generate && npm run start

I had previously a pre-deploy command which does nothing as not change on the filesystem is permitted and version 6 was refering to the @prisma/client to run...

About 7 hours to solve...


Status changed to Solved Railway 19 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...