Skip to content

After corepack disable npm Corepack cannot be updated #692

Closed as duplicate

Description

@MikeMcC399

Current behavior

If Corepack is disabled for npm (for instance after enabling it) and an attempt is made to update Corepack, then the installation of Corepack according to the instructions in the README > Manual Installs > Update Corepack using npm fail since npm is no longer available.

Expected behavior

  1. Corepack should issue a prompt and a warning about the consequences of executing corepack disable npm
  2. The README document should describe how to recover after executing corepack enable npm and then needing to disable npm with respect to Corepack.

Versions

Corepack 0.31.0
Ubuntu 24.04.2 LTS
Node.js 22.14.0 LTS

Steps to reproduce

corepack enable npm
corepack disable npm
npm install -g corepack@latest

Activity

  1. styfle commented on Mar 31, 2025

    @styfle
    SponsorMember

    Sounds similar to #112

  2. MikeMcC399 commented on Mar 31, 2025

    @MikeMcC399
    ContributorAuthor

    @styfle

    Yes, it's related. There is also a description in that issue of the difficulty that Corepack would have if it tried to save and restore the previous status.

    For yarn or pnpm after disabling them through corepack, you can install them globally with npm, so the workaround is fairly simple.

    I guess it's subjective whether having to reinstall Node.js to reinstall the bundled npm version is regarded as simple.

    corepack enable doesn't enable npm by default, you have to explicitly specify corepack enable npm. I would guess that there are low numbers of users of Corepack with npm, although I have no real way of knowing. I expect this is why the issue hasn't been reported previously.

  3. styfle commented on Mar 31, 2025

    @styfle
    SponsorMember

    I would guess that there are low numbers of users of Corepack with npm, although I have no real way of knowing.

    There are about 15k public repos using it on github:

    https://github.com/search?q=%22%5C%22packageManager%5C%22%3A+%5C%22npm%40%22+path%3Apackage.json&type=code

  4. aduh95 commented on Mar 31, 2025

    @aduh95
    Contributor

    What does corepack npm i -g corepack@latest do?

  5. MikeMcC399 commented on Apr 1, 2025

    @MikeMcC399
    ContributorAuthor

    @aduh95

    What does corepack npm i -g corepack@latest do?

    The following sequence is successful in updating Corepack to latest (currently 0.32.0), tested in the environment:

    Corepack 0.31.0
    Ubuntu 22.04.2 LTS
    Node.js 22.14.0 LTS installed using the n Node.js version manager

    corepack enable npm
    corepack disable npm
    corepack npm install -g corepack@latest

    Should this be added to the documentation?

    Logs

    $ node -v
    npm -v
    corepack -v
    corepack enable npm
    corepack disable npm
    corepack npm install -g corepack@latest
    corepack -v
    v22.14.0
    10.9.2
    0.31.0
    
    changed 1 package in 897ms
    0.32.0
    
  6. MikeMcC399 commented on Apr 1, 2025

    @MikeMcC399
    ContributorAuthor

    @styfle

    Thanks for the search string! It turns out that npm usage (14.8k) is followed by Yarn v1 Classic (28.2k), then Yarn Modern (68.7k), with pnpm (120k) at the top of the list.

  7. MikeMcC399 commented on Apr 1, 2025

    @MikeMcC399
    ContributorAuthor

    This also affects other npm commands that are not project based, for example:

    corepack disable npm
    npm view corepack version
    npm owner ls corepack

    This can be worked around by prefixing each npm command with corepack:

    $ corepack disable npm
    corepack npm view corepack version
    corepack npm owner ls corepack
    0.32.0
    nodejs-foundation <build@iojs.org>
    
  8. aduh95 commented on Apr 1, 2025

    @aduh95
    Contributor

    I think we can close this as duplicate then, if npm is not installed or has been uninstalled, you may use corepack npm – or you need to (re)install it – to run npm commands.

  9. MikeMcC399 commented on Apr 1, 2025

    @MikeMcC399
    ContributorAuthor

    Yes, the root cause is a duplicate of #112
    Issue #112 does not however mention any suggestion to add the restriction to the README documentation or to add the advice on how to update Corepack to the README after having executed corepack disable npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions