question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated client with custom path: ENOENT: no such file or directory, open 'D:\<projectpath>\node_modules\.prisma\client\schema.prisma

See original GitHub issue

Bug description

Hello, i’ve commented on #10512 and told to create a new issue.

I tried creating a client in a custom path with the @prisma/client@dev but when loading the created client it throws ENOENT: no such file or directory, open 'D:\development\<project-workspace>\node_modules\.prisma\client\schema.prisma'.

this is the schema used to generate the client


generator client {
  provider        = "prisma-client-js"
  output          = "./client"
  previewFeatures = ["interactiveTransactions"]
  binaryTargets = ["linux-musl", "darwin", "windows"]
}

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

I use this to generate a npm private library because I need multiple prisma clients with different schemas, so I import each of them from the corresponding library:


const client1 = await import('@myorg/prisma1').PrismaClient
const client2 = await import('@myorg/prisma2').PrismaClient

const prismaClient1 = new client({ datasources: { db: { url: this.prepareUrl(factoryOptions) } } })

But upon instantiating any one of them it produces that ENOENT error.

The libraries I mentioned have the following folder structure when installed in the consuming project:

inside node_modules/@myorg: image

How to reproduce

  • generate a prisma client with a custom path on a separate directory.
  • Install the directory as a dependency on another project
  • Load the generated client from the custom directory into the project
  • Instantiate the client

Expected behavior

It would be expected the generated client to be capable of loading the runtime and prisma.schema from within it’s own directory when an output path is specified on the .schema

Prisma information


generator client {
  provider        = "prisma-client-js"
  output          = "./client"
  previewFeatures = ["interactiveTransactions"]
  binaryTargets = ["linux-musl", "darwin", "windows"]
}

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

Environment & setup

  • OS: windows
  • Database: mysql
  • Node.js version: 16

Prisma Version

prisma                  : 3.13.0-dev.3
@prisma/client          : 3.13.0-dev.3
Current platform        : windows
Query Engine (Node-API) : libquery-engine ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : ba8e3c2c2615e6af9303b3930e7de9377999a0e7
Studio                  : 0.459.0

ALSO TRIED WITH

Environment variables loaded from .env
prisma                  : 3.12.0
@prisma/client          : 3.12.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 22b822189f46ef0dc5c5b503368d1bee01213980
Studio                  : 0.459.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
roxworkscommented, Sep 17, 2022

Getting something similar on a monorepo multi zone nextjs project

Trying to use prisma in an internal package but each app is giving a prisma error - unable to find schema.prisma same as here

I’m using custom generated client location, and have tried without a files [] and with, haven’t found any success

if I manually copy paste the schema.prisma into the next build, it seems to at least cause different errors, but all the same feels like there’s still something I’m missing here?

Tried based on @TheVoid-0’s comments to adjust a files[] to include the .node files etc but wasn’t able to get any working config off of that

2reactions
TheVoid-0commented, Apr 9, 2022

Yes @janpio you are correct, the only files missing on the published library were the query engines .node ones, once I’ve included them all started working without any problems so far. It looks like if they are missing, prisma fall back to look for everything on the default location node_modules/.prisma Wich will not exist in this scenario. Not sure what prisma should do, but perhaps showing an error message that the query engines are missing would give a better hint that something in the building and/or packaging went wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating the client (Concepts) - Prisma
This page explains how to generate Prisma Client. It also provides additional context on the generated client, typical workflows and Node.js configuration.
Read more >
Prisma engines
Learn about Prisma internals and how it works "under the hood". Prisma tools are based on an engine-layer which manages the communication with...
Read more >
How to deploy a Prisma app to Vercel
Learn how to deploy to Vercel a Next.js app that uses a serverless REST API in conjunction with Prisma Client.
Read more >
Prisma | Next-generation ORM for Node.js & TypeScript
Prisma is a next-generation Node.js and TypeScript ORM for PostgreSQL, MySQL, SQL Server, SQLite, MongoDB, and CockroachDB. It provides type-safety, ...
Read more >
Environment variables - Prisma
When you use Prisma CLI or Prisma Client, the .env file content and the variables defined in there are put into the system's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found