corepack icon indicating copy to clipboard operation
corepack copied to clipboard

How to corepack self update?

Open rotu opened this issue 2 years ago • 3 comments
trafficstars

How should I update the version of corepack?

Since corepack is installed system-wide with Node, it's likely that existing installations (like my Windows machine) will have outdated versions.

For example, the LTS Node installer installs 0.18.0 but the latest version is 0.20.0 and has commands that don't exist in previous versions.

A couple options:

  • Edit $PATH so the C:\Users\dan\AppData\Roaming\npm comes before C:\Program Files\nodejs and npm install --global corepack
  • Alias corepack='npx corepack@latest' in my shell profile.
  • Use a package manager to overwrite the global corepack: cd 'C:\Program Files\nodejs'; npm install corepack@latest --prefix .
  • Don't install corepack using the Node installer. Instead npm install --global corepack

rotu avatar Sep 04 '23 17:09 rotu

I think just running npm install --global corepack@latest is fine which will replace the symlink to the corepack binary shipped with the node installation? Maybe not on Windows 🤷🏻‍♂️

simonhaenisch avatar Oct 24 '23 10:10 simonhaenisch

No, on Windows it is not working

inoyakaigor avatar Oct 31 '23 11:10 inoyakaigor

The first workaround offered by @rotu works well on windows if corepack is already installed through your nodejs install, though you may have to move the path of nodejs from system to user variables.

gskyu avatar Mar 21 '24 07:03 gskyu