You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node Sass安装失败后npm全局包安装受阻问题求助

Fixing npm ETIMEDOUT Errors After Failed Node Sass Install

Hey fellow dev, I’ve run into this exact kind of network-related npm headache before—reinstalling Node alone doesn’t always cut it when proxy/registry settings get messed up. Let’s walk through actionable fixes to get your npm installs working again:

1. Clear Proxy Settings First

ETIMEDOUT often happens when npm is stuck trying to route traffic through an old or invalid proxy. Let’s clean that up:

  • Check current proxy configs:
    npm config get proxy
    npm config get https-proxy
    
  • If either returns a URL, delete them immediately:
    npm config delete proxy
    npm config delete https-proxy
    
  • Also, double-check if you have a system-wide proxy or VPN running—turn those off temporarily and test again.

2. Switch to a Reliable npm Registry

The default npm registry can be slow or blocked in some regions. Switch to a stable mirror to bypass network bottlenecks:

  • To use it for a single install command:
    npm install --global --production windows-build-tools --registry=https://registry.npmmirror.com
    
  • To set it permanently (so you don’t have to add the flag every time):
    npm config set registry https://registry.npmmirror.com
    

After setting this, retry your other commands like npm install -g @angular/cli or npm install -g node-gyp.

3. Manually Configure node-gyp Dependencies

Windows-build-tools failing can break node-gyp, which many packages (including Node Sass) rely on. Let’s set this up manually:

  • Install Python 2.7 (node-gyp doesn’t work well with Python 3.x yet) and add it to your system PATH.
  • Tell npm where to find Python:
    npm config set python python2.7
    
  • Set the correct MSVC version (match the Visual Studio version you have installed—2017/2019 are common):
    npm config set msvs_version 2017
    
  • Now install node-gyp globally:
    npm install -g node-gyp
    

4. Reset npm Cache

Corrupted cache can also cause weird network timeouts. Let’s wipe it clean:

npm cache clean --force

Close your terminal/command prompt, reopen it, and try your installs again.

5. Check Firewall/Antivirus

Sometimes security tools block npm’s outgoing requests. Temporarily disable your firewall or antivirus, then run the install commands. If it works, add npm to the whitelist of your security software.

Bonus: Try a Specific Node LTS Version

If you installed the latest Node version, it might have compatibility issues with older packages like Node Sass. Use nvm (Node Version Manager) to install an LTS version:

  • Install nvm, then run:
    nvm install 16.18.0
    nvm use 16.18.0
    

Then retry your npm installs—LTS versions are more stable for most legacy packages.

内容的提问来源于stack exchange,提问作者gerald ferron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 18:57:37