`prisma generate` fails in yarn2 / yarn3 workspaces
See original GitHub issueBug description
We are using prisma in a yarn2 monorepo consisting of multiple workspaces. We were on version 2.23.0 before and everything was working fine. After upgrading to 2.29.0, prisma tries to run npm to install @prisma/client
, even though it’s already installed in the current folder. This fails, as npm is unable to recognize the imported workspace.
yarn prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:core-api-plugins/article-import-edeka
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/valentinmorlock/.npm/_logs/2021-08-16T10_13_58_979Z-debug.log
Error: Command failed with exit code 1: npm install -D prisma@2.29.1
How to reproduce
clone this repo: https://github.com/v-morlock/prisma-yarn2-repro
yarn
cd workspace
yarn prisma generate
Expected behavior
Prisma should generate its files
Prisma information
Environment & setup
- OS: macOS
- Database: mySQL
- Node.js version: 16.1.0
Prisma Version
2.29.1, stopped working on 2.26.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Using Prisma with Yarn v3 - Stack Overflow
The problem lies in how Yarn is resolving imports. Prisma CLI generates the client (by default) to node_modules/.prisma . Even when nodeLinker ...
Read more >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 >Building a Monorepo with Yarn 2 - Heroku Blog
Yarn 2 is officially supported by Heroku. Here's a popular use case for Yarn enhanced by Yarn 2: using workspaces to manage dependencies...
Read more >Building a sane Docker image for Typescript, Yarn ... - Medium
Building a sane Docker image for Typescript, Yarn Workspaces and Prisma 2 · First, you can see that it's a multistage build. ·...
Read more >JavaScript package managers compared: npm, Yarn, or pnpm?
Yarn Berry goes even further by ditching node_modules completely with its Plug'n'Play (PnP) mode. In this article, we'll cover the following ...
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
For what it’s worth, the following changes were sufficient in my case. I’m using Prisma with Yarn 3 (zero-installs / plug ‘n’ play) in a monorepo.
I started from @nishils’s suggestion (which worked) and simplified it as much as I could while still keeping everything functional:
prisma
and@prisma/client
as per the docsnode_modules
:pnpify
to be able to run the command-line scriptIf anyone is interested here’s the patch we use to get prisma to work fully with PnP. It just swaps prisma’s bundled
resolve
for an actual require statement, and disables a sanity check that assumes the location of the prisma client, which doesn’t make sense in a PnP world. To get this to work, you’ll also need to add apackageExtension
toprisma
to get it to installresolve
as a dependency. With all this, we have prisma working fully with PnP in a workspace set up. This patch is for prisma 2.30.3, but I’m guessing that you’d only need to perform similar patching in a newer version.