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.

Prisma dependencies installed outside of directory being invoked from in split setup

See original GitHub issue

Bug description

We have a project setup as follows:

/db
  /migrations
  dev.db-journal
  schema.prisma
/server
  /node_modules
  .gitignore
  index.js
  package-lock.json
  package.json

This means the server is not in charge of the db, but rather we can in the future have the same db used by many different web apps, or some other interesting distributed setups.

The server directory has all Prisma dependencies included, and we run all npx prisma commands from there. However, when running commands from the server directory, like: npx prisma migrate dev --schema ../db/schema.prisma for example, we see that Prisma installs dependences into the db folder:

/db
  /migrations
  /node_modules       👈
  dev.db-journal
  package-lock.json   👈
  package.json        👈
  schema.prisma
/server
  /node_modules
  .gitignore
  index.js
  package-lock.json
  package.json

Is this expected? It feels odd since we are saying we want the client installed into output = "../server/node_modules/.prisma/client" and we are running the command from the server directory, which has all dependencies required.

Another unfortunate byproduct of this is if we change the Prisma version under server, it will not update the versions under db.

How to reproduce

  • Clone: https://github.com/shayneczyzewski/prisma-db-folder-setup-issue as git clone https://github.com/shayneczyzewski/prisma-db-folder-setup-issue.git
  • cd into server directory
  • npm install deps
  • Run: npx prisma generate --schema ../db/schema.prisma
  • See you now have npm install artifacts (node_modules, package*.json) under db now

Expected behavior

No node_modules directory or package*.json files under db.

Prisma information

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

generator client {
  provider = "prisma-client-js"
  output = "../server/node_modules/.prisma/client"
}

model Foo {
  id Int @id @default(autoincrement())
  bar String
}

Environment & setup

  • OS: macOS Monterey Version 12.2
  • Database: SQLite
  • Node.js version: v14.16.0

Prisma Version

prisma                  : 3.9.2
@prisma/client          : 3.9.2
Current platform        : darwin
Query Engine (Node-API) : libquery-engine bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : bcc2ff906db47790ee902e7bbc76d7ffb1893009
Studio                  : 0.457.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shayneczyzewskicommented, Dec 14, 2022

Actually, I am having a hard time reproducing in a simpler setup, so likely related to this split setup @janpio. Holding off on another issue until/unless I can repro in a simpler setup. Thanks again 👍🏻

1reaction
shayneczyzewskicommented, Dec 14, 2022

If you think this is not exactly the same problem a new issue would be nice. We are actually focussing on these right now, so we will go through all these soon with a comb to try to understand what is going on there. Thanks!

Sounds good, thanks @janpio. Since I am not fully sure, I will create a new issue. Appreciate you and the team giving this some eyes soon. 🙏🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating the client (Concepts)
This hook invokes the prisma generate command which in turn generates the Prisma Client code into the default location node_modules/.prisma/client . Notice that ......
Read more >
TypeScript, PostgreSQL, Prisma Backend | REST API ...
Clone the repository. The source code for the series can be found on GitHub. To get started, clone the repository and install the...
Read more >
Prisma schema (Reference)
The Prisma schema is the main configuration file when using Prisma. It is typically called schema.prisma and contains your database connection and data ......
Read more >
Fullstack app with TypeScript, Next.js, Prisma & GraphQL
This script adds four links and one user to your database using Prisma Client. A look at the project structure and dependencies. You...
Read more >
Prisma CLI Installation (Reference)
npm install prisma --save-dev. This should add prisma to the devDependencies in your package.json . You can then invoke the locally installed CLI...
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