Prisma dependencies installed outside of directory being invoked from in split setup
See original GitHub issueBug 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 directorynpm 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:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
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 👍🏻
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. 🙏🏻