EAI_NONAME is a DNS error indicating the hostname could not be found. Check your internet connection, verify DNS configuration, and remove incorrect proxy settings.
EAI_NONAME is a DNS (Domain Name System) resolution error that occurs when npm cannot translate a hostname into an IP address. The error indicates that the requested hostname is invalid, no longer exists, or cannot be resolved by your system's DNS server. When you run `npm install`, npm attempts to fetch packages from registry.npmjs.org and other dependencies, but if DNS resolution fails at any point, this error is thrown. This is distinct from temporary network failures (EAI_AGAIN) but indicates a more fundamental hostname lookup problem.
First, confirm that your internet connection is working and DNS is resolving hostnames:
# Check if you can reach the npm registry
ping registry.npmjs.org
# On Windows, flush DNS cache
ipconfig /flushdns
# On macOS/Linux
sudo dscacheutil -flushcache # macOS
sudo systemctl restart systemd-resolved # LinuxIf ping fails or times out, your DNS is not resolving.
Incorrect proxy settings are a common cause. Clear any proxy configuration from npm:
# Remove HTTP proxy
npm config rm proxy
# Remove HTTPS proxy
npm config rm https-proxy
# Verify proxy settings are cleared
npm config get proxy
npm config get https-proxyIf you need to use a proxy (corporate environment), configure it correctly:
npm config set proxy http://username:password@proxy-host:port
npm config set https-proxy http://username:password@proxy-host:portIf you're on WSL2, Linux, or Docker, update your DNS configuration to use public DNS servers:
# Edit /etc/resolv.conf
sudo nano /etc/resolv.conf
# Add or replace nameserver entries with:
nameserver 8.8.8.8
nameserver 8.8.4.4
# Or Cloudflare DNS:
nameserver 1.1.1.1
nameserver 1.0.0.1Network-specific issues may require switching networks:
# Disconnect from corporate/home network
# Connect to a different network (mobile hotspot, public WiFi, etc.)
# Try npm install on the new network
npm installIf npm install succeeds on a different network, the issue is with your original network's DNS or proxy configuration.
Network services may have stale state. Restart them:
# Windows - restart network adapter through troubleshooter
# Open Settings > Network & Internet > Status > Network troubleshooter
# macOS
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# Linux
sudo systemctl restart systemd-resolved
# Docker
docker-compose down
docker-compose upOutdated npm versions may have DNS bugs. Update both:
# Update npm globally
npm install -g npm@latest
# Check versions
node --version
npm --version
# Clear npm cache
npm cache clean --force
# Clear npm package-lock to force fresh resolution
rm package-lock.json
# Try install again
npm installEAI_NONAME differs from EAI_AGAIN (temporary failure)—it's a permanent hostname lookup failure. In corporate environments, internal DNS servers may not be reachable from Docker/WSL containers by default. Corporate proxies sometimes intercept and filter npm registry requests even when proxy settings appear correct. For CI/CD pipelines, ensure the runner's network configuration allows egress to registry.npmjs.org:443. For persistent WSL2 issues, check both wsl.conf and .wslconfig for DNS options—they differ based on your WSL version.
npm error code E401 npm error Incorrect or missing password.
How to fix 'E401 Unable to authenticate' errors with npm private registries
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm