GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `npm install -g` keeps the `bin` link on the old version after the default Node.js changes · Issue #3279 · voidzero-dev/vite-plus

npm install -g keeps the bin link on the old version after the default Node.js changes #3279

New issue
Copy link
New issue
Copy link
Closed
Bug
#3283
Closed
npm install -g keeps the bin link on the old version after the default Node.js changes#3279
Bug
#3283
Copy link
Assignees
mondaychen
Labels
bugSomething isn't workingtriage: failed

Description

@mondaychen
mondaychen
opened on Oct 29, 2026
Issue body actions

Describe the bug

When Vite+ manages Node.js, npm install -g <pkg> installs the package into the prefix of the active Node.js version. Vite+ then links the package binary into ~/.vite-plus/bin/ and records the owner in ~/.vite-plus/bins/<bin>.json.

When the active Node.js version changes (for example, the latest LTS moves from 24 to 26), I run npm install -g <pkg> again to update the package. npm installs a new copy into the new Node.js prefix and reports success. But the link in ~/.vite-plus/bin/ still points to the copy in the old Node.js prefix. Vite+ shows no message. When I run the command, I get the old version.

Expected: the link points to the copy that npm just installed, or Vite+ tells me that it kept the old link.

Cause: in check_npm_global_install_result, Vite+ replaces an existing link only when a different npm package owns it. When the same package owns it, Vite+ skips it, and it does not compare the link target with the new npm bin directory:

vite-plus/crates/vp_global_cli/src/shim/dispatch.rs

Lines 287 to 313 in 7073d61

false
};
if shim_exists {
if let Ok(Some(config)) = BinConfig::load_sync(&bin_name) {
if config.source == BinSource::Vp {
// Managed by vp install -g — warn about the conflict
managed_conflicts.push((bin_name, config.package.clone()));
} else if config.source == BinSource::Npm && config.package != package_name {
// Link exists from a different npm package — recreate link for new owner.
// The old symlink points at the previous package's binary; we must
// replace it so it resolves to the new package's binary in npm's bin dir.
#[cfg(unix)]
let source_path = npm_bin_dir.join(&bin_name);
#[cfg(windows)]
let source_path = npm_bin_dir.join(vt_str::format!("{bin_name}.cmd"));
if source_path.as_path().exists() {
let _ = std::fs::remove_file(shim_path.as_path());
create_bin_link(
&bin_dir,
&bin_name,
&source_path,
&package_name,
node_version,
);
}
}

Possible fix: also replace the link when the same package owns it but the link target is not in the current npm bin directory. Write the new nodeVersion to the bin config, and print a line such as Relinked 'agent-browser' to Node.js 26.13.0 (was 24.15.0).

I can submit a PR for this fix.

Related: #1986 (general discussion about npm install -g and Node.js version management).

Reproduction

No repository is necessary. This is global CLI behavior. See the steps below.

Steps to reproduce

# 1. Install a package with an older default Node.js version
vp env default 24
npm install -g cowsay          # Answer "Y" to create the link
ls -l ~/.vite-plus/bin/cowsay  # -> .../js_runtime/node/24.x.y/bin/cowsay

# 2. Change the default Node.js version, then install the package again
vp env default 26
npm install -g cowsay          # npm reports success; Vite+ prints nothing
ls -l ~/.vite-plus/bin/cowsay  # Still -> .../node/24.x.y/bin/cowsay
cat ~/.vite-plus/bins/cowsay.json   # "nodeVersion" is still 24.x.y

# The new copy exists, but the link does not use it
ls ~/.vite-plus/js_runtime/node/26.*/lib/node_modules/cowsay

Workaround: remove the link (rm ~/.vite-plus/bin/cowsay), then run npm install -g cowsay again; or run vp install -g instead of npm install -g.

On my machine, 7 links point to old Node.js versions (24.15.0, 24.18.0, 24.21.0), while the active version is 26.13.0.

System Info

$ vp env current
Environment:
  Version  26.13.0
  Source   lts

Tool Paths:
  node  /Users/user/.vite-plus/js_runtime/node/26.13.0/bin/node
  npm   /Users/user/.vite-plus/js_runtime/node/26.13.0/bin/npm
  npx   /Users/user/.vite-plus/js_runtime/node/26.13.0/bin/npx

$ vp --version
vp v0.2.1

Local vite-plus:
  vite-plus  Not found

Environment:
  Package manager  Not found
  Node.js          v26.13.0

macOS, npm 10.9.9. The code at the link above is from current main (7073d61), so the bug is also on main.

Used Package Manager

npm

Activity

  1. mondaychen
    changed the title [-]`npm install -g` keeps the `~/.vite-plus/bin` link on the old Node.js version after the default Node.js changes[/-] [+]`npm install -g` keeps the `bin` link on the old version after the default Node.js changes[/+] on Oct 29, 2026
  2. voidzero-bot commented on Oct 29, 2026

    @voidzero-bot
    voidzero-botBot
    on Oct 29, 2026 · Hidden as resolved
    show commentMore actions
  3. voidzero-bot
    added
    triage: failed
    on Oct 29, 2026
  4. liangmiQwQ
    assigned
    mondaychen
    on Oct 29, 2026
  5. liangmiQwQ
    added
    bugSomething isn't working
    on Oct 29, 2026
  6. liangmiQwQ
    added the
    Bug
    issue type on Oct 29, 2026
  7. fengmk2
    closed this as completedin #3283on Nov 20, 2026
  8. fengmk2
    added a commit that references this issue on Nov 20, 2026

    fix(shim): move npm global links to the reinstalled Node.js version (v…

    This issue will close once commit 23754b3 is merged into the 'main' branch.
    23754b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mondaychen
    mondaychen

Labels

bugSomething isn't workingtriage: failed

Type

Bug

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.