Prisma 3.9.x+ multiple clients being generated, and in the wrong Yarn 1 workspace
See original GitHub issueBug description
In yarn 1 workspaces, sometimes prisma will create the .prisma folder at one or more of the nested workspaces’ node_modules.
Migrations and generation produces the client in the root node_modules/.prisma
but when running inside a workspace, it picks a different prisma client, causing this error
In our case:
├── node_modules
│ ├── .prisma # 👈 this is good!
├── web
│ ├── node_modules
├── api
│ ├── node_modules
│ │ ├── .prisma # 😨 whai?
Node version: v16.13.1 Yarn version: 1.23.0-20220130.1630 (set using yarn version classic)
How to reproduce
Reproduction is in this repo here:
- https://github.com/dac09/prisma-multiple-clients-repro
- To launch on gitpod: https://gitpod.io/#https://github.com/dac09/prisma-multiple-clients-repro
Steps to reproduce:
- Check that theres no prisma folder in api/node_modules
ls -la api/node_modules
- Go into api and generate prisma client
cd api && yarn rw prisma generate
- Notice that prisma has now been generated in api node_modules
❯ ls -a api/node_modules
. .. .prisma
- And to see the actual problem this causes run:
yarn rw prisma migrate dev
# equivalent to
# yarn prisma migrate dev --schema "./api/db/schema.prisma"
and then
yarn rw prisma db seed
And you should see:
PrismaClientKnownRequestError:
Invalid `db.post.create()` invocation in
/Users/dac09/Experiments/prisma-repro/scripts/seed.ts:24:41
21
22 Promise.all(
23 posts.map(async (post) => {
→ 24 const newPost = await db.post.create(
The table `main.Post` does not exist in the current database.
at Object.request (/Users/dac09/Experiments/prisma-repro/node_modules/@prisma/client/runtime/index.js:39809:15)
at PrismaClient._request (/Users/dac09/Experiments/prisma-repro/node_modules/@prisma/client/runtime/index.js:40637:18)
at /Users/dac09/Experiments/prisma-repro/scripts/seed.ts:24:27
at async Promise.all (index 0) {
code: 'P2021',
clientVersion: '3.10.0',
meta: { table: 'main.Post' }
Expected behavior
Prisma should only generate client at root of the workspace, not in nested workspaces.
Prisma information
Schema: https://github.com/dac09/prisma-multiple-clients-repro/blob/main/api/db/schema.prisma Query: https://github.com/dac09/prisma-multiple-clients-repro/blob/main/api/src/services/posts/posts.ts#L6
Environment & setup
- OS: MacOS, Linux, Windows
- Database: Tested with SQLite, but likely problem with all DBs
- Node.js version: 16.13.1
Prisma Version
prisma : 3.10.0
@prisma/client : 3.10.0
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio : 0.458.0
Mirrored Redwood Issue
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top 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 >Achieving end-to-end type safety in a modern JS GraphQL stack
In this article, we will create a simple GraphQL application, a message board, by combining many recent open-source technologies.
Read more >Prisma 3.12.0 Release - GitClear
fix(client): use findSync only if no __dirname (#12427) ... 3.9.x+ multiple clients being generated, and in the wrong Yarn 1 workspace ...
Read more >prisma - npm
You can use Prisma in new projects or add it to an existing one. ... 4.9.0-integration-feat-client-ext-generic-type-api.1.
Read more >error parsing error: this experimental syntax requires enabling one ...
To expand on Ceroy's answer (source):. Install dependencies needed to enable babel to properly parse jsx. yarn add @babel/preset-react -D.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Last known working version (in Redwood world) - Prisma 3.8.1
@millsp hope this helps! ✌️
@millsp Thank you so much! So you have transparency with our timeline, we are targeting March 21 for a “final” v1-rc, with stable v1 to follow within a couple of weeks. This is one of the last remaining issues on my radar — not meant to imply pressure but just so you know why I’m watching it more closely 😆