Windows11下安装Angular CLI遇ENOTFOUND错误,求解决方法
Hey there, let's work through this npm registry resolution issue together—it's super common when dealing with network or proxy settings on Windows. Here are some practical steps to get your Angular CLI installed smoothly:
1. Clear Invalid Proxy Configurations
First, check if npm has leftover or incorrect proxy settings that might be blocking access:
- Run these commands in Command Prompt or PowerShell to view current proxy configs:
npm config get proxy npm config get https-proxy - If either returns a value (especially an unreachable proxy address), delete them with:
npm config delete proxy npm config delete https-proxy
2. Switch to a Domestic npm Registry
The official npm registry might be slow or unreachable from your network. Try using a reliable domestic mirror like npmmirror (formerly Taobao):
- Temporary fix (use only for this installation):
npm install -g @angular/cli --registry=https://registry.npmmirror.com - Permanent fix (set as default for all future npm commands):
npm config set registry https://registry.npmmirror.com - Verify the change with
npm config get registry—it should return the mirror URL you set.
3. Fix DNS Resolution Issues
The error indicates npm can't resolve registry.npmjs.org, which points to a DNS problem. Try these steps:
- First, run
ping registry.npmjs.orgin Command Prompt. If it fails to resolve the address, switch your DNS server:- Go to Settings > Network & Internet > Advanced network settings > More network adapter options
- Right-click your active network connection and select Properties
- Find Internet Protocol Version 4 (TCP/IPv4), double-click it
- Select Use the following DNS server addresses and enter:
- Preferred DNS server:
8.8.8.8(Google DNS) or114.114.114.114(domestic public DNS) - Alternate DNS server:
8.8.4.4or114.114.115.115
- Preferred DNS server:
- Save changes and flush your DNS cache with
ipconfig /flushdns
4. Reset Windows Network Stack
Corrupted network settings can cause unexpected connection issues. Reset them with these admin-level commands:
- Open Command Prompt as Administrator
- Run these commands one by one:
ipconfig /flushdns netsh winsock reset netsh int ip reset - Restart your computer and try installing Angular CLI again.
5. Check Firewall/Antivirus Interference
Sometimes Windows Defender or third-party antivirus software blocks npm's network requests:
- Temporarily disable your firewall/antivirus, then run
npm install -g @angular/cliagain. - If the installation succeeds, add
npm.exe(usually located inC:\Program Files\nodejs\) to your firewall's allowed apps list to avoid future blocks.
6. Reinstall Node.js (Last Resort)
If all other steps fail, a clean Node.js install might fix hidden configuration glitches:
- Uninstall Node.js from Settings > Apps > Installed apps
- Download the Node.js 18.13.0 installer (match your PC's architecture)
- Run the installer with default settings, then try installing Angular CLI once more.
内容的提问来源于stack exchange,提问作者fatiha chaibi

