Skip to content

Improve npm install -g and Node.js version management #1986

Open
0 of 1 issue completed
Open

Description

@liangmiQwQ

Reference: #1974 (comment), #1974 (comment)

Vite+ injects a prompt when npm install -g finishes and create shims to make bins accessible when the npm prefix is not in $PATH. This logic sometimes causes tricky bugs (#1974 (comment)), and there is some overlap with vp install -g responsibilities.

According to #528, #540, npm install -g is used to satisfy users who want to install packages in one certain Node.js's bin directory. And the bin should be usable only when using this Node version.

I believe the there is a room to improve the interaction logic here.

Activity

  1. liangmiQwQ commented on Jun 30, 2026

    @liangmiQwQ
    CollaboratorAuthor

    Option 1 (Reference from @liangmiQwQ in #1974 (comment)): To remove the npm wrapper logic, always append the corresponding Node bin directory to $PATH, make bins only accessible when using the corresponding Node.js.

    Option 2 (Reference from @fengmk2 in #1974 (comment)): Stop making shims for packages installed by npm install -g, prompt users to use vp install -g instead.

    For Option 1, I think it is hard for the current architecture. The active Node.js version changes with the current working directory. That means we need to implement a fnm/nvm like logic, continuously monitor directory changes and update $PATH accordingly.

    For Option 2, I think we should require users to use vp install -g, similar to Volta. Vite+ has borrowed Volta's _VOLTA_TOOL_RECURSION and PATH-prepending approach, if npm install -g is still allowed, the ghost bin problem cannot be fully solved.

    Vite+ currently prepends the active Node.js bin directory to $PATH. This directory includes not only core Node.js tools, but other installed tools, such as tsc installed via npm install -g typescript. Those binaries are normally not accessible from the shell, but prepending the Node.js bin directory to $PATH makes them visible to child processes and scripts.

    Alternatively, we could explore a different architecture from Volta, based on VP_NODE_VERSION and Node shims instead of Volta's recursion + PATH-prepending approach. The shims could resolve the appropriate Node.js version on each invocation, avoiding the need to expose the entire Node.js bin directory.

  2. changed the title [-]Improve `npm install -g`[/-] [+]Improve `npm install -g` and Node.js version management[/+] on Jun 30, 2026
  3. fengmk2 commented on Jun 30, 2026

    @fengmk2
    Member
  4. TheAlexLichter commented on Jul 1, 2026

    @TheAlexLichter
    Member

    I'll dig into this a bit more.

    Right now I think the npm shim is really helpful for people who aren't from the frontend world and "only know npm", eg from tutorials etc.

  5. liangmiQwQ commented on Jul 1, 2026

    @liangmiQwQ
    CollaboratorAuthor

    npm shim is really helpful for people who aren't from the frontend world and "only know npm"

    Volta just directly navigates npm install -g's install directory to Volta managed global directory. So installed packages are invisible in npm list -g, I don't know whether it is beginner-friendly 😂

  6. added theissue type on Jul 23, 2026
  7. ranjith7022 commented on Oct 3, 2026

    @ranjith7022

    Hi
    Just following up on this — any thoughts on improving the "npm install -g" / Node.js version management interaction, especially around the injected prompt and shims? Thanks!

  8. liangmiQwQ commented on Oct 3, 2026

    @liangmiQwQ
    CollaboratorAuthor

    Hi Just following up on this — any thoughts on improving the "npm install -g" / Node.js version management interaction, especially around the injected prompt and shims? Thanks!

    Hi! Feel free to share your idea!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Target date

    None yet

    Start date

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions