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.

Postinstall script fails with PNPM workspaces due to npm ERR! Cannot read properties of null (reading 'matches')

See original GitHub issue

Bug description

When running pnpm install in a monorepo, with this structure

packages
    server
         prisma
               schema.prisma
    shared-utils
         package.json
    web
         package.json
pnpm-workspace.yaml
package.json

I get this error:

#0 2.239
#0 2.239 > @hub/shared-utils@1.0.0 generate /app/packages/shared-utils
#0 2.239 > pnpm prisma generate
#0 2.239
#0 36.80 Prisma schema loaded from ../server/prisma/schema.prisma
#0 451.1 npm ERR! Cannot read properties of null (reading 'matches')
#0 451.2
#0 451.2 npm ERR! A complete log of this run can be found in:
#0 451.2 npm ERR!     /root/.npm/_logs/2022-08-23T02_34_57_814Z-debug-0.log
#0 451.2 Error: Command failed with exit code 1: npm install -D prisma@3.15.2
#0 451.3 undefined
#0 451.3 /app/packages/shared-utils:
#0 451.3  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @hub/shared-utils@1.0.0 generate: `pnpm prisma generate`
#0 451.3 Exit status 1

my package shared-utils installs prisma, web depends on shared-utils

shared-utils has a custom postinstall script, which generates Prisma client from custom location(from server package). This is package.json of shared-utils

{
  "name": "@example/shared-utils",
  "version": "1.0.0",
  "main": "dist/src/index.js",
  "types": "dist/src/index.d.ts",
  "private": true,
  "license": "MIT",
  "scripts": {
    "build": "rm -rf dist && tsc --build",
    "test": "jest",
    "precommit": "eslint --ext .ts \"*/**/*\" --fix && prettier --write .",
    "postinstall": "pnpm prisma generate"
  },
  "dependencies": {
    "currency.js": "^2.0.4",
    "@prisma/client": "3.15.2",
    "date-fns": "^2.28.0"
  },
  "devDependencies": {
    "@example/eslint-config": "1.0.0",
    "@example/prettier-config": "1.0.0",
    "prisma": "3.15.2"
  },
  "prisma": {
    "schema": "../server/prisma/schema.prisma"
  },
  "prettier": "@example/prettier-config",
  "jest": {
    "preset": "ts-jest",
    "roots": [
      "src"
    ],
    "modulePaths": [
      "src"
    ],
    "moduleDirectories": [
      "node_modules"
    ]
  }
}

How to reproduce

  1. Go to project root.
  2. Run pnpm install
  3. See error

Expected behavior

pnpm install installs packages, and Prisma schema is generated automatically

Prisma information

Environment & setup

  • OS: Mac OS,
  • Database: PostgreSQL
  • Node.js version: 16.13.1

Prisma Version

3.15.2

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ErlanBelekovcommented, Aug 29, 2022

adding public-hoist-pattern[]=*prisma* to .npmrc file fixed this issue, took the solution from here

https://github.com/prisma/prisma/issues/12921

0reactions
ErlanBelekovcommented, Aug 24, 2022

@janpio when will Prisma support PNPM? 👀

seems like this is related to these issues, but I still haven’t managed to make it work https://github.com/prisma/prisma/issues/9848 https://github.com/prisma/prisma/discussions/12501

Read more comments on GitHub >

github_iconTop Results From Across the Web

fails to install on ubuntu, pnpm@latest, typescript@beta, react ...
Cannot read properties of null (reading 'matches') npm ERR! A complete log of this run can be found in: npm ERR!
Read more >
npm cannot read properties of null (reading 'matches') - You.com ...
prisma/prismaPostinstall script fails with PNPM workspaces due to npm ERR! Cannot read properties of null (reading 'matches')#14944. Created 3 months ago.
Read more >
npm ERR! Cannot read properties of null ... - Stack Overflow
my npm version is 8.1.4 and i solve this problem by running : npm cache clear --force.
Read more >
.npmrc | pnpm
However, if some tooling only works when the hoisted dependencies are in the root of node_modules , you can set this to true...
Read more >
Npm install command failing with message "could not find ...
When I run the npm install command, npm starts downloading the dependencies. But then, suddenly, it stops with the error: npm ERR! code...
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