Using Corepack
Since v16.13, Node.js is shipping Corepack for managing package managers. This is an experimental feature, so you need to enable it by running:
bash
复制代码
corepack enable pnpm
If you installed Node.js using Homebrew, you'll need to install corepack separately:
You can pin the version of pnpm used on your project using the following command:
bash
复制代码
corepack use pnpm@latest
This will add a "packageManager" field in your local package.json which will instruct Corepack to always use a specific version on that project. This can be useful if you want reproducability, as all developers who are using Corepack will use the same version as you. When a new version of pnpm is released, you can re-run the above command.