You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve npm install -g and Node.js version management #1986
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.
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.
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 😂
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 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!
Activity
liangmiQwQ commentedon Jun 30, 2026
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 usevp install -ginstead.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/nvmlike 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_RECURSIONand PATH-prepending approach, ifnpm install -gis still allowed, the ghost bin problem cannot be fully solved.Alternatively, we could explore a different architecture from Volta, based on
VP_NODE_VERSIONand 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.[-]Improve `npm install -g`[/-][+]Improve `npm install -g` and Node.js version management[/+]fengmk2 commentedon Jun 30, 2026
cc @TheAlexLichter
TheAlexLichter commentedon Jul 1, 2026
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.
liangmiQwQ commentedon Jul 1, 2026
Volta just directly navigates
npm install -g's install directory to Volta managed global directory. So installed packages are invisible innpm list -g, I don't know whether it is beginner-friendly 😂ranjith7022 commentedon Oct 3, 2026
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!
liangmiQwQ commentedon Oct 3, 2026
Hi! Feel free to share your idea!