Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to corepack self update? #305

Closed
rotu opened this issue Sep 4, 2023 · 16 comments
Closed

How to corepack self update? #305

rotu opened this issue Sep 4, 2023 · 16 comments

Comments

@rotu
Copy link

rotu commented Sep 4, 2023

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
@simonhaenisch
Copy link

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 🤷🏻‍♂️

@inoyakaigor
Copy link

No, on Windows it is not working

@gskyu
Copy link

gskyu commented Mar 21, 2024

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.

@codersjj
Copy link

The preferred option is to use the Corepack version that is distributed along with Node.js itself. So if you want to update Corepack, you can update your Node.js version. 😃

@hyunbinseo
Copy link

No, on Windows it is not working

It does work on Windows 11. This is what I've used to workaround these issues:

node -v
# v22.13.1

corepack -v
# 0.30.0

npm install -g corepack@latest
# changed 1 package in 463ms

corepack -v
# 0.31.0 

@trevor-hackett
Copy link

trevor-hackett commented Feb 6, 2025

No, on Windows it is not working

It does work on Windows 11. This is what I've used to workaround these issues:

node -v

v22.13.1

corepack -v

0.30.0

npm install -g corepack@latest

changed 1 package in 463ms

corepack -v

0.31.0

This did not work for me. I had to uninstall NodeJS and then reinstall it, making sure to disable the corepack integration in the installer. After it was reinstalled without corepack, I could manage corepack via npm. Hopefully this helps someone out.

@MikeMcC399

This comment has been minimized.

@inoyakaigor
Copy link

Just checked updating:

Image

Still don't work. Also checked in new instance of CMD

W11 24h2
Nodejs 23.6, installed with default options from msi package

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Feb 7, 2025

@inoyakaigor

As @trevor-hackett described, you need to disable the "corepack manager" feature if you installed Node.js using a Windows msi package and you want to update the version of Corepack.

You can access this through Windows Settings > Apps > Installed Apps
Select Node.js and then Modify

Image

Then if you execute

npm install -g corepack@latest

it will install Corepack globally and Windows will not have two different versions of Corepack installed - one from msi and another from npm.

@MikeMcC399
Copy link
Contributor

I would like to suggest adding an "Updating Corepack" section to the README to describe how to update Corepack after installing Node.js according to any of the methods described on the Download Node.js page.

@MikeMcC399
Copy link
Contributor

@MikeMcC399
Copy link
Contributor

Please check the updated Corepack Manual Installs section which includes additional advice for dealing with Windows Installer .msi installations when manually updating with npm:

Image

@rotu rotu closed this as completed Feb 7, 2025
@inoyakaigor
Copy link

@MikeMcC399 I don't get it. Please point me where I wrong.
Previously I have installed corepack with Nodejs. After the latest discussions I've deinstalled Nodejs and installed the latest 23.7.0 with uncheked the "corepack" checkbox. Then I've ran npm i -g corepack
Executed corepack enable and corepack use [email protected] at my project's folder.

At this point I'm expecting that everything will work as previously with as Nodejs has installed within Corepack. But it doesn't.

I'm getting an error:
corepack not found

The path node_modules/corepack/dist/yarn.js I found in C:\Program Files\nodejs\yarn.ps1 that starts by C:\Program Files\nodejs\yarn.CMD

Am I reinstalled corepack wrong or something else?

@MikeMcC399
Copy link
Contributor

@inoyakaigor

Could you please open a separate issue for this? You have discovered a different issue working with Node.js msi.

This issue is closed, so it is not a good place to be looking at a new problem.

If you open a new issue I can give you some tips about what you should do next.

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Feb 10, 2025

@inoyakaigor

The short version of the advice to you is as follows, since Node.js 23.7.0 already has the fix:

  1. npm uninstall -g corepack
  2. Modify the Node.js msi app and Change "corepack manager" to "Will be installed on local drive"

If you want more detail, then please open a new issue.

@MikeMcC399
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants