EAI_NODATA is a DNS error indicating the DNS server responded but had no records for the hostname. Configure public DNS servers, check proxy settings, or verify network connectivity.
EAI_NODATA is a DNS resolution error that occurs when the operating system's DNS resolver attempts to look up the npm registry domain but receives a response indicating that no data is available for that domain. Unlike ENOTFOUND (where the DNS server doesn't recognize the domain), EAI_NODATA means the DNS server responded but had no DNS records (A or AAAA) for the requested host. This is a temporary DNS failure that typically indicates network connectivity issues, misconfigured DNS servers, or transient resolution problems.
First verify basic network connectivity is working:
# Test general internet connectivity
ping google.com
ping 8.8.8.8
# Test DNS resolution for the npm registry
nslookup registry.npmjs.org
dig registry.npmjs.orgIf ping works but nslookup/dig fails, your DNS resolver is the problem.
Start with a clean slate by clearing npm's cache and removing potentially conflicting proxy settings:
# Clear npm cache
npm cache clean --force
# Remove proxy settings
npm config rm proxy
npm config rm https-proxy
# Verify no proxy is set
npm config get proxy
npm config get https-proxyThen try npm install again.
Change your DNS resolver to a reliable public DNS service:
On Linux (including WSL):
sudo nano /etc/resolv.conf
# Add or replace with public DNS servers at the top
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1On macOS:
networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4On Windows:
Settings → Network & Internet → Change adapter options → Right-click connection → Properties → IPv4 → Preferred DNS: 8.8.8.8
If getting EAI_NODATA inside Docker, configure DNS in your container:
Method 1: Docker daemon configuration
sudo nano /etc/docker/daemon.json
# Add or update:
{
"dns": ["8.8.8.8", "8.8.4.4", "1.1.1.1"]
}
# Restart Docker
sudo systemctl restart dockerMethod 2: Docker Compose
services:
app:
image: node:18
dns:
- 8.8.8.8
- 8.8.4.4Configure npm to retry failed requests and increase timeout thresholds:
# Increase timeout to 60 seconds
npm config set fetch-timeout 60000
# Set retry policy
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 5000
npm config set fetch-retry-maxtimeout 60000
# Now try again
npm installIf the primary npm registry has issues, switch to an alternative registry or mirror:
# Use Taobao mirror (fast in Asia, works globally)
npm config set registry https://registry.npmmirror.com
# Clear cache and retry
npm cache clean --force
npm install
# To revert to default npm registry
npm config set registry https://registry.npmjs.org/EAI_NODATA is distinct from similar DNS errors: ENOTFOUND means the domain doesn't exist or DNS server didn't respond, while EAI_AGAIN means a temporary timeout occurred. EAI_NODATA specifically means the DNS server responded but had no records for that host. Docker users should note that Alpine Linux images sometimes have stricter DNS handling—switching to Debian-based images (bookworm-slim, bullseye) may resolve persistent issues without configuration changes.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error
npm ERR! code CERT_SIGNATURE_FAILURE npm ERR! Certificate signature failure
How to fix 'npm ERR! code CERT_SIGNATURE_FAILURE' certificate signature failure