[Node.js] Lock down pnpm version in package.json
"engines": { "pnpm": "10"}Use pnpm to manage pnpm versions
As of pnpm v10, it can manage which version of itself to use, based on the packageManager field in package.json.
First, install pnpm globally:
npm install -g pnpmThen, set the packageManager field in your project’s package.json to the version of pnpm you want to use for your project. Example:
"packageManager": "pnpm@10.4.1"Now, regardless of the global version of pnpm you have installed (as long as it’s v10+), when you run pnpm commands in your project, it will use the version specified in package.json.
Use corepack to manage pnpm versions
You can use corepack to manage the correct version of pnpm for you, if you’d like.
First enable it (once) with:
corepack enableThen run:
corepack use pnpm@latestThis will download and install the latest version of pnpm and set that exact version in the packageManager field of your package.json.
Now, when you run pnpm commands, corepack will ensure the correct version is used.