Repository navigation
vp env shouldn't intercept npm i -g #540
Description
Some notes:
- binaries installed by
npm i -gwill disappear is an already knonw behavior of fnm and nvm. This is a already a solid mental model for node users. I don't see a solid reason to break this mental model. How to install global npm tools that are available across all node versions Schniz/fnm#109 also introduce. - Volta introduces different behavior with an explicitly different command
volta installinstead ofnpm i -g.- Notice Votal also intercepts
npm i -g. For Volta, it's also the same betweenvolta installandnpm i -g
- Notice Votal also intercepts
Comparison Table
┌───────┬───────────────────────────────────┬──────────────────────────────────────────────────────────┐
│ Tool │ Default Behavior │ Built-in Workaround │
├───────┼───────────────────────────────────┼──────────────────────────────────────────────────────────┤
│ fnm │ Isolated per-version │ None (users complain) │
├───────┼───────────────────────────────────┼──────────────────────────────────────────────────────────┤
│ nvm │ Isolated per-version │ nvm reinstall-packages to copy from another version │
├───────┼───────────────────────────────────┼──────────────────────────────────────────────────────────┤
│ mise │ Isolated per-version │ .default-npm-packages auto-install, npm backend │
├───────┼───────────────────────────────────┼──────────────────────────────────────────────────────────┤
│ Volta │ Isolated + pinned to Node version │ Explicit design - volta install with clear communication │
└───────┴───────────────────────────────────┴──────────────────────────────────────────────────────────┘
My proposal: Do not make npm i -g special
Reasons to Distinguish vp env install from npm i -g
1. Principle of Least Surprise
npm i -g has had the same behavior for 15+ years. Every Node developer knows:
- Global packages go to the current Node version's directory
- Switching Node versions means different global packages
Intercepting and changing this behavior silently violates user expectations. Even Volta, which does intercept, prints note: using Volta to install Yarn — acknowledging it's doing something unexpected.
2. Explicit is Better Than Implicit
vp env installexplicitly says "I want vite-plus to manage this"npm i -gshould mean "I'm using npm directly"
Users who want isolation should ask for it. Users who want standard npm behavior shouldn't have to learn why their mental model is broken.
3. Migration Path from fnm/nvm
fnm and nvm users have muscle memory: npm i -g installs to current version, packages disappear when switching. This is annoying but understood.
If vite-plus intercepts npm i -g and isolates everything, these users face:
- Unexpected behavior change
- Confusion about where packages actually live
- No way to get the "old" behavior without env vars
4. Debugging and Transparency
When npm i -g does what npm normally does:
- Users can reason about the system
npm list -gshows what's installed- Standard npm troubleshooting applies
When intercepted:
- Users don't know what's actually happening
npm list -gmay show different results than expected- Adds a layer of magic that obscures problems
5. Two Distinct Use Cases Exist
Use case A: "I want typescript globally for this Node version"
→ npm i -g typescript (traditional, per-version)
Use case B: "I want typescript to always work regardless of Node version"
→ vp env install typescript (isolated, pinned)
These are different intents. One command shouldn't try to serve both.
6. Volta's Quirks Are a Warning
Volta intercepts npm i -g, but:
- Updates require
volta install(confusing) --dry-runflag is ignored (bug from interception complexity)- pnpm global installs aren't intercepted (inconsistent)
Interception adds complexity and edge cases. Keeping commands separate avoids this.
7. Composability with Other Tools
Some users may want vite-plus only for Node version management, while using other tools (or raw npm) for package management. Interception forces an all-or-nothing approach.
Summary: Let npm i -g be npm i -g. Let vp env install be the explicitly better alternative. Users who want isolation will find it; users who don't won't be surprised.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
linear commentedon Feb 4, 2026
VP-176
[-]`vite env` shouldn't intercept `npm i -g`[/-][+]`vp env` shouldn't intercept `npm i -g`[/+]hyfdev commentedon Feb 5, 2026
New version follows this behavior.