`npm install -g` keeps the `bin` link on the old version after the default Node.js changes
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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
- Ngôn ngữ chính
- Rust
- Star
- 6.5k
- Fork
- 297
- Merge trung bình
- 23 giờ 42 phút
- Pull request đã merge (30 ngày)
- 233
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/vite-plus
-
triage: not actionable
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
voidzero-dev/vite-plus#3296 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
voidzero-dev/vite-plus#3235 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docker guide: the runtime stage needs libatomic1 for Node.js 25 and laterCó thể đã có người làm @kshanxs đã nhận 7 ngày trước. Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
voidzero-dev/vite-plus#3219 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
voidzero-dev/vite-plus#2882 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`vp migrate`: warn when the workspace uses TurborepoCó thể đã có người làm @voidzero-bot đã nhận hôm nay. Đang mở- P3: minor bug enhancement triage: fix verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
voidzero-dev/vite-plus#3298 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/vite-plus
Issue tương tự
-
comp-view potential bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
ClickHouse/ClickHouse#128410 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Save As onto the project's own .snxprj overwrites it with a schematic and the project can no longer openCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea: app data-loss priority: high type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
lan_bot: 13 of 15 tests fail on main (minecraft:dialog entries carry data with the known pack)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởskip-release
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
horizon-rust/horizon#5505 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: cloud S3: minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
manaflow-ai/cmux#29709 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:mem good first issue priority:low type:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày