setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

Set npm/yarn/pnpm version

Open ghost opened this issue 3 years ago • 6 comments

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.

ghost avatar Jun 27 '22 09:06 ghost

Hi @stijn-gravity, thank you for your proposal, we will consider it.

vsafonkin avatar Jun 27 '22 11:06 vsafonkin

I will be opening a PR on this!

haneenmahd avatar Jul 30 '22 03:07 haneenmahd

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

jasikpark avatar Aug 02 '22 15:08 jasikpark

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

kidonng avatar Sep 14 '22 10:09 kidonng

This should be solved by #531

nickserv avatar Sep 24 '22 07:09 nickserv

Also see #546

styfle avatar Sep 28 '22 14:09 styfle