npm install Slow on VPN?
Speed Up Your Package Downloads
Key Takeaways
VPNs add latency and bandwidth limits to npm registry connections
Each package download suffers from VPN overhead—hundreds of packages means minutes of waiting
Route Terminal outside VPN for full-speed installs
Why npm Is Slow on VPN
The npm registry (registry.npmjs.org) uses a global CDN optimized for fast downloads. But when you're on VPN, every request takes a detour through your corporate server first.
- •
Added latency per request
- •
Bandwidth throttling on VPN connection
- •
Hundreds of packages = hundreds of slow requests
- •
Each small package multiplies the overhead
How Slow Are We Talking?
The difference is dramatic:
- •
Normal npm install: 30 seconds
- •
On VPN: 5-10 minutes (or more)
- •
Large projects with deep node_modules: Even worse
- •
Fresh installs after clearing cache: Painful
Quick Test
# Time an install off VPN
time npm install lodash
# Connect VPN, clear cache
npm cache clean --force
# Time again
time npm install lodashCompare the times. The VPN overhead becomes obvious.
Fix 1: Use npm Cache
# Prefer offline packages when available
npm install --prefer-offlineThis helps for repeat installs of the same packages. But your first install is still slow.
Fix 2: Use yarn or pnpm
These package managers have better caching and parallel downloads:
# pnpm is especially fast
npm install -g pnpm
pnpm installStill affected by VPN, but the parallelization helps.
Fix 3: Route Terminal Direct (Best)
The most effective fix: route your Terminal outside the VPN tunnel.
Install SplitTunnel on your Mac
Add Terminal to "Direct" routing
npm connects directly to the registry CDN
Full-speed installs while work apps stay on VPN
No configuration changes. No registry switching. Just fast installs.
Other Package Managers That Benefit
Route Terminal direct and all these speed up:
- •
npm / yarn / pnpm (Node.js)
- •
pip (Python)
- •
gem (Ruby)
- •
cargo (Rust)
- •
go get (Go)
- •
composer (PHP)
Any package manager downloading from public registries benefits from direct routing.
Private npm Registries
If your company uses a private npm registry that requires VPN access, you have options:
- •
Keep Terminal on VPN when installing private packages
- •
Route Terminal direct for public package installs
- •
Switch routing based on what you're working on
SplitTunnel makes it easy to toggle Terminal's routing as needed.
Verifying the Speed Improvement
After setting up SplitTunnel with Terminal routed direct:
# Clear cache for clean test
npm cache clean --force
# Connect VPN
# Time a fresh install
time npm install express
# Should match non-VPN speedsFrequently Asked Questions
Install at Full Speed
Route Terminal direct while work apps stay on VPN. npm just works.
7-day free trial · Cancel anytime