`npm install -g` keeps the `bin` link on the old version after the default Node.js changes
維護者通常 1 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
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:
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 (7073d613), so the bug is also on main.
Used Package Manager
npm
- 主要語言
- Rust
- 星號
- 6.5k
- 分支
- 297
- 平均合併
- 1 天 59 分鐘
- 30 天內合併 PR
- 235
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
voidzero-dev/vite-plus 的其他 Issue
-
pending triage
難度 2/5 1-3 小時 新手友好度 63/100
voidzero-dev/vite-plus#3235 ·
維護者通常 1 天內回覆
-
Docker guide: the runtime stage needs libatomic1 for Node.js 25 and later可能已有人在做 @kshanxs 於 7 天前認領。 未關閉documentation
難度 2/5 1-3 小時 新手友好度 84/100
voidzero-dev/vite-plus#3219 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
pending triage
難度 2/5 1-3 小時 新手友好度 72/100
voidzero-dev/vite-plus#2882 · 2 則留言 ·
維護者通常 1 天內回覆
-
vpx: support ECMAScript decorators after upstream Oxc support lands可能已有人在做 @fengmk2 於 1 天前認領。 未關閉
voidzero-dev/vite-plus#3292 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Executables throwing可能已有人在做 @voidzero-bot 於 1 天前認領。 未關閉- P2: has workaround pending triage triage: fix verified
難度 4/5 3-5 天 新手友好度 20/100
voidzero-dev/vite-plus#3290 · 1 則留言 ·
維護者通常 1 天內回覆
查看 voidzero-dev/vite-plus 的全部 Issue
相似的 Issue
-
bug duplicate enhancement priority: low ui
難度 2/5 1-3 小時 新手友好度 62/100
storytold/pdfcraft#5594 · 1 則留言 ·
維護者通常 1 天內回覆
-
documentation good first issue help wanted
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
open-jarvis/OpenJarvis#1212 ·
維護者通常 4 天內回覆
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 84/100
CakeRepository/agentshangout#38 ·
維護者通常 1 天內回覆