镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

pnpm stuck on 7.1.7 under corepack #225

Closed

Description

@hyperknot

Copying pnpm issue here: pnpm/pnpm#5875

pnpm version: 7.1.7

Code to reproduce the issue:

corepack prepare pnpm@7.22.0 --activate; pnpm -v

Expected behavior:

It should output I'm on 7.22.0

Actual behavior:

Preparing pnpm@7.22.0 for immediate activation...
7.1.7

Additional information:

  • node -v prints: v16.17.1
  • Windows, macOS, or Linux?: macOS, nvm
which pnpm
~/.nvm/versions/node/v16.17.1/bin/pnpm

Activity

  1. merceyz commented on Jan 3, 2023

    @merceyz
    Member

    Have you run corepack enable? Your reproduction is missing it;

    $ docker run --rm node:16.17.1 bash -c "corepack prepare pnpm@7.22.0 --activate; pnpm -v"
    Preparing pnpm@7.22.0 for immediate activation...
    bash: pnpm: command not found

    vs

    $ docker run --rm node:16.17.1 bash -c "corepack enable; corepack prepare pnpm@7.22.0 --activate; pnpm -v"
    Preparing pnpm@7.22.0 for immediate activation...
    7.22.0
  2. hyperknot commented on Jan 3, 2023

    @hyperknot
    Author

    Yes, I've done corepack enable the first time I installed it, otherwise I wouldn't have been able to use pnpm.

    But now, I've run it again, just for testing and after that I'm able to do the upgrade.

    So the bug report is basically this: To update pnpm, I need to repeatedly run corepack enable, before each update.

  3. arcanis commented on Jan 3, 2023

    @arcanis
    Contributor

    Something happened that caused the binary to be overwritten. It's not possible to say what for certain with the info you have, but Corepack doesn't remove them by itself, so it points to a third-party issue.

    Some Node.js version managers in particular are known to forget the Corepack status when switching between Node versions. Given you use nvm, it's likely what happened here.

  4. styfle commented on Jan 3, 2023

    @styfle
    SponsorMember

    Also try echo $PATH or echo %PATH% which will show you the precedence of which directories are searched on your machine. As mentioned above, likely nvm path is prepended in front of the corepack path which is causing it to prefer nvm.

  5. hyperknot commented on Jan 3, 2023

    @hyperknot
    Author

    The path is good, it's the same as it was when the bug was present.

    which pnpm
    ~/.nvm/versions/node/v16.17.1/bin/pnpm
    

    I definitely haven't done anything with global packages. What I have done though is I removed some of my cache folders after migrating to pnpm. What does corepack enable do exactly? Could I have broken it by deleting my cache folders?

  6. aduh95 commented on Feb 24, 2023

    @aduh95
    Contributor

    What does corepack enable do exactly?

    It adds the binaries to your path, next to the node one:

    corepack/README.md

    Lines 128 to 138 in 5633a15

    ### `corepack enable [... name]`
    | Option | Description |
    | --------------------- | --------------------------------------- |
    | `--install-directory` | Add the shims to the specified location |
    This command will detect where Node.js is installed and will create shims next
    to it for each of the specified package managers (or all of them if the command
    is called without parameters). Note that the npm shims will not be installed
    unless explicitly requested, as npm is currently distributed with Node.js
    through other means.

    If you're using nvm, I'm not sure how this works as I believe it exposes different node binary depending on the context.

    Could I have broken it by deleting my cache folders?

    What cache folders?

  7. hyperknot commented on Feb 27, 2023

    @hyperknot
    Author

    Just the npm, yarn, etc. cache folders I found under home dir and Library.

  8. mrhammadasif commented on May 9, 2023

    @mrhammadasif

    I would like to add that the corepack looks for the packageManager property in package.json, Just make sure to update that as well to the latest version.

  9. iapetos163 commented on Jun 10, 2023

    @iapetos163

    I was facing the same issue and it turns our my problem was due to the package.json configuration. I ran this command

    $ corepack prepare pnpm@8.6.1 --activate
    Preparing pnpm@8.6.1 for immediate activation...
    

    Despite the command and its output, corepack actually installs pnpm@7.1.8 because that's what's specified in package.json.

    This is very confusing behavior. I would consider it more intuitive for corepack to always install an explicitly-given version, and maybe output a warning if the version in package.json does not match.

  10. aduh95 commented on Feb 21, 2024

    @aduh95
    Contributor

    I think #291 has addressed this, you can now use corepack use … and corepack up (and skip the corepack prepare command). Closing, let me know if I missed something.

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