Search code examples
node.jswindowspnpm

`pnpm install`: "ERROR This project is configured to use ^pnpm"


I have forked an open source project that uses pnpm. I am using Windows with Node 18.

I have installed pnpm using npm install -g pnpm as per https://pnpm.io/installation#using-npm

In the project directory, I ran pnpm install and it fails with the following error:

$ pnpm install
 ERROR  This project is configured to use ^pnpm
For help, run: pnpm help install

There is no "packageManager" field in the package.json file. If I add one with value pnpm, I still see the same error.

How can I fix this? The project won't install properly with npm, so I think I need to use pnpm.

Here is a detailed repro log:

# I'm using "Git Bash" on Windows
$ uname -a
MINGW64_NT-10.0-22631 my-machine 3.4.7-25de8b84.x86_64 2023-08-28 21:32 UTC x86_64 Msys

$ node --version
v18.20.4

$ npm install -g pnpm
...

$ pnpm --version
9.12.3

$ git clone git@github.com:astahmer/openapi-zod-client.git
Cloning into 'openapi-zod-client'...

$ cd openapi-zod-client/lib/

$ pnpm install
 ERROR  This project is configured to use ^pnpm
For help, run: pnpm help install

$ pnpm --version
 ERROR  This project is configured to use ^pnpm
For help, run: pnpm help


Solution

  • The "^pnpm" comes from the package.json in workspace root of the repository (https://github.com/astahmer/openapi-zod-client/blob/main/package.json#L18)

    There seems to be a misunderstanding about the format of the "packageManager" entry in package.json. Current pnpm (9.12.3) reports the error:

    ERROR  This project is configured to use ^pnpm

    It seems it started with pnpm 9.7.0. That's probably why it works for developers of openapi-zod-client (9.7.0 is about 3 months old: https://www.npmjs.com/package/pnpm?activeTab=versions)

    BTW, corepack reports a similar error:

    UsageError: Unsupported package manager specification (^pnpm@8.2.0)

    "packageManager" entry is documented in https://nodejs.org/api/packages.html#packagemanager as <package manager name>@<version>. Such, if you need to work with the repository, just remove "^" in https://github.com/astahmer/openapi-zod-client/blob/main/package.json