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 Generate appears to be Incompatible with PNPM

See original GitHub issue

Bug description

For any project using pnpm (in my experience), prisma initializes however when running prisma generate, it behaves very bizarrely, it first audits all packages in the entire dependency tree (which takes quite a while, though I’m assuming this is the standard pnpm audit and ultimately fails. Of course, after deleting node_modules and running npm i and then npx prisma generate works fine. A complete log after running pnpx prisma generate is below:

⨯ david@DAVID-LAPTOP  ~\Documents\Dev\prisma-bugtesting 
❯ pnpx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma

up to date, audited 11 packages in 2m

26 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated querystring@0.2.0: The
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated istanbul@0.4.5: This module is no longer maintained, try this instead:
npm WARN deprecated   npm i nyc
npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'C:\Users\david\Documents\Dev\prisma-bugtesting\node_modules\ntypescript\bin\lib.scripthost.d.ts.DELETE.0dce1c2244b7f40b86ed4413f9126831'

added 1793 packages, changed 1 package, and audited 1800 packages in 4m

141 packages are looking for funding
  run `npm fund` for details

10 vulnerabilities (4 low, 6 moderate)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
Error: Could not resolve @prisma/client despite the installation that we just tried.
Please try to install it by hand with npm install @prisma/client and rerun prisma generate 🙏.

How to reproduce

Follow the start from scratch guide exactly, and prior to the migration step, just run prisma generate (who wants to migrate a test DB anyways?).

Essentially though, in package.json:

  "devDependencies": {
    "@types/node": "^16.0.1",
    "prisma": "^2.26.0",
    "ts-node": "^10.0.0",
    "typescript": "^4.3.5"
  }

and tsconfig.json:

{
  "compilerOptions": {
    "sourceMap": true,
    "outDir": "dist",
    "strict": true,
    "lib": ["esnext"],
    "esModuleInterop": true
  }
}

with the above schema file. That’s all I kept in this test project. Make sure pnpm is used.

Expected behavior

This should in theory work identically to how it does with npm and yarn, at least if pnpm is “supported” by the Prisma ecosystem. I suspect that for some reason prisma is behaving differently because pnpm uses hard linking to a store OR because prisma doesn’t use the flat node_modules structure that npm/yarn do (see docs). However, I suspect it may be the former issue, since the issue persists even when installing dependencies via pnpm install --shamefully-hoist which recreates the flat structure of npm and yarn.

If PNPM is decidedly not supported (which would be quite unfortunate), then I think that should be documented (and I couldn’t find this anywhere).

Prisma information

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

generator client {
  provider = "prisma-client-js"
}

model Example {
  id String @id @default(uuid())
  description String
  solution String
}

Environment & setup

  • OS: Verified on Windows, but likely in other environments as well.
  • Database: PostgreSQL
  • Node.js version: 15.3.0
  • PNPM version 6.9.1

Prisma Version

prisma               : 2.26.0
@prisma/client       : Not found
Current platform     : windows
Query Engine         : query-engine 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\.pnpm\@prisma+engines@2.26.0-23.9b816b3aa13cc270074f172f30d6eda8a8ce867d\node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine     : migration-engine-cli 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\.pnpm\@prisma+engines@2.26.0-23.9b816b3aa13cc270074f172f30d6eda8a8ce867d\node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\.pnpm\@prisma+engines@2.26.0-23.9b816b3aa13cc270074f172f30d6eda8a8ce867d\node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary        : prisma-fmt 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\.pnpm\@prisma+engines@2.26.0-23.9b816b3aa13cc270074f172f30d6eda8a8ce867d\node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 9b816b3aa13cc270074f172f30d6eda8a8ce867d
Studio               : 0.408.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
pantharshit00commented, Jul 10, 2021

PNPM is definitely supported, we use it ourselves in this repository 😃 : https://github.com/prisma/prisma/blob/master/src/pnpm-workspace.yaml

We just merged a fix for pnpm: https://github.com/prisma/prisma/pull/7942

Can you please try version 2.27.0-dev.54 and see if that works for you? If this is still not resolved, we will have another look here.

1reaction
dkantereivincommented, Jul 13, 2021

Fixed in 2.27.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.npmrc | pnpm
This will make stacktraces cleaner as paths to dependencies will be one directory higher. NOTE: the virtual store cannot be shared between several...
Read more >
npm err! cannot read properties of undefined (reading 'name')
The solution was to run the command npm init to create a "complete" package.json file. Open side panel. npm ERR! Cannot read properties....
Read more >
Prisma and node.js complex module issues - Stack Overflow
I have type files, resolver files, service files, and module files for each model, but prisma seems to be having some strange errors....
Read more >
Upgrade Guide (v4) - NextAuth.js
So instead of having one in Prisma syntax, one in TypeORM syntax, etc. we've decided to just make one for each underlying database...
Read more >
eslint | Yarn - Package Manager
Make sure your plugins (and ESLint) are both in your project's package.json as devDependencies (or dependencies, if your project uses ESLint at runtime)....
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