What you see
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/react failed, reason: connect ETIMEDOUT 104.16.0.35:443
npm ERR! network This is a problem related to network connectivity.Common causes
- A slow or congested path between the runner and registry.npmjs.org, common on shared and self-hosted runners.
- A corporate proxy or firewall that npm is not configured to use.
- IPv6 routes that are advertised but do not work, so connections hang before falling back to IPv4.
- Large installs that open hundreds of connections at once.
How to fix it
- 01
Give npm more patience
Raise the fetch timeout and retry count. This hides short hiccups but makes slow builds slower.
.npmrc fetch-retries=5 fetch-retry-mintimeout=20000 fetch-retry-maxtimeout=120000 fetch-timeout=300000 - 02
Tell npm about your proxy
If the runner sits behind a proxy, npm needs to know it.
shell npm config set proxy http://proxy.internal:3128 npm config set https-proxy http://proxy.internal:3128 - 03
Fetch from a cache near the runner
Move the registry closer. With a registry cache in the same region, packages already pulled once never cross the slow path again.
.npmrc registry=https://acme.cacheport.cc/npm/ //acme.cacheport.cc/npm/:_authToken=${CACHEPORT_TOKEN}