setup-node
setup-node copied to clipboard
Set npm/yarn/pnpm version
Description: Similar to how we can set the node version I'd like to set the npm version.
node-version: 1.16.x
npm-version: 8.5.5
There is a similar issue here https://github.com/actions/setup-node/issues/213, but it's for a different reason and this one can be resolved by setting the node version. However this is not enough for the problems I have been facing.
Justification: Currently I am struggling with a bug in npm from versions 8.11 to 8.13. These are automatically installed when you chose node version 1.16. This means I have to set back my npm version so the ci can run, which I can do in an extra ci step.
However to me the issue is that the npm version will change over time, without our input. We'd like control over this to prevent issues like the one above from showing up.
Are you willing to submit a PR? Not currently but I might in the future.
Hi @stijn-gravity, thank you for your proposal, we will consider it.
I will be opening a PR on this!
Two options for specifying a solution could be querying the volta section of the package.json if you manage versions via that, or via the engines portion of the package.json https://docs.npmjs.com/cli/v8/configuring-npm/package-json#engines
You can "set" npm/yarn/pnpm version if you use corepack:
corepack [email protected] install
corepack [email protected] install
corepack [email protected] install
Or manually install package managers:
npm install [email protected]
yarn set version a.b.c
npm install [email protected] # Or use pnpm/action-setup which has a version option
This should be solved by #531
Also see #546