Skip to content

npm shim does not consult packageManager field #1629

Description

@bouzlibop

Describe the bug

npm shim (running $HOME/.vite-plus/bin/npm) does not consult packageManager field. This is confusing. While node --version will properly print the version, which respect .node-version. npm --version will use resolved Node.js npm version not the one specified in packageManager field.

Steps to reproduce

  1. Install npm@11.14.1: npm i -g npm@11.14.1.
  2. Set packageManager field to npm@11.14.0: npm pkg set npm@11.14.0
  3. Run vp install -- --verbose and then npm --version.

Expected:
Both commands should respect packageManager field. They both should print 11.14.0.

Actual:
vp install -- --verbose prints npm info using npm@11.14.0, which is expected, but npm --version print 11.14.1, which is confusing.

System Info

`vp v0.1.21`

`which npm` is `$HOME/.vite-plus/bin/npm`

Used Package Manager

npm

Validations

Activity

  1. added theissue type on May 19, 2026
  2. fengmk2 commented on May 20, 2026

    @fengmk2
    Member

    Currently, we will not change npm's version selection logic. Only when running package manager-related commands with vp will the packageManager config be followed.

  3. bouzlibop commented on May 20, 2026

    @bouzlibop
    Author

    Could you explain a bit more? What's confusing to me is that node --version properly reports the version resolved for a given project. Why then npm --version works differently instead of also giving project specific results?

  4. bouzlibop commented on May 20, 2026

    @bouzlibop
    Author

    Also, the output of vp env current does not report npm version:

    Vite+ - The Unified Toolchain for the Web
    
    Environment
      Version   22.22.0
      Source    devEngines.runtime
      Source Path   $HOME/src/myapp/package.json
      Project Root   $HOME/src/myapp
    
    Tool Paths:
      node  $HOME/.vite-plus/js_runtime/node/22.22.0/bin/node
      npm  $HOME/.vite-plus/js_runtime/node/22.22.0/bin/npm
      npx  $HOME/.vite-plus/js_runtime/node/22.22.0/bin/npx
    

    In order to check what is the resolved npm version which vp will use in a given project I did vp install -- --version, which feels more like a hack than a proper approach. Is there a better way?

    It would be helpful if we could print the resolved package manager, its version, source and source path similarly to Node info we have in the Environment part. Then it would be clear which package manger vp sees and why.

  5. fengmk2 commented on May 21, 2026

    @fengmk2
    Member

    @cpojer What do you think? Should we make npm/pnpm/yarn handle it similarly to node's lookup logic? Prioritize using the configuration version of the current project, and fall back to the global version only if not found?

  6. cpojer commented on May 21, 2026

    @cpojer
    Member

    Yes I think we should if packageManager explicitly declares npm@<version>. If the project is configured with pnpm /yarn/bun, it should not turn an npm install into a pnpm install.

  7. fengmk2 commented on May 21, 2026

    @fengmk2
    Member

    Okay, I will refer to the version lookup logic of node. npm/pnpm/yarn shims will run the correct version based on the packageManager field.

  8. assigned and unassigned on May 21, 2026
  9. changed the issue type fromtoon May 21, 2026
  10. added this to the Beta milestone on May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Fields

Priority

None yet

Start date

None yet

Target date

None yet

Effort

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions