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

求助:使用ng new创建Angular项目时npm 5.8.0报错,启动旧项目也异常

Troubleshooting Sudden Angular CLI & npm Errors

Hey there, let's work through this issue together. Based on your environment details (Node v8.11.1, npm v5.8.0, Angular CLI v6.0.0) and the fact that problems popped up suddenly—even affecting existing projects—here are actionable fixes to try:

Common Fixes to Try

1. Clear the npm Cache

Corrupted cache files are one of the most frequent causes of random npm/Angular CLI errors. Let's reset it:

npm cache clean --force

After running this, attempt to create a new Angular project again.

2. Reinstall the Angular CLI Globally

Your global Angular CLI installation might have become corrupted somehow. Let's uninstall and reinstall the exact version you're using to avoid compatibility mismatches:

npm uninstall -g @angular/cli
npm install -g @angular/cli@6.0.0

3. Update npm to a Compatible Version

npm 5.8.0 has some known bugs, and it pairs better with Node 8.11.1 when using npm 6.x (the latest stable branch compatible with Node 8). Update npm with:

npm install -g npm@6.14.18

4. Fix Existing Project Dependencies

For your existing projects throwing errors, corrupted node_modules or lock files are often the culprit. Follow these steps:

  1. Delete the node_modules folder and package-lock.json file
  2. Refresh dependencies with:
    npm install
    

5. Check Permissions

Permission issues can block npm from installing packages properly:

  • On macOS/Linux: Try running commands with sudo (or fix your npm permissions long-term to avoid needing sudo)
  • On Windows: Launch your terminal as Administrator before executing commands

6. Rule Out Network/Proxy Issues

If your network changed recently or you're behind a proxy, npm might fail to download packages. Test basic connectivity with:

npm install lodash

If this fails, check your network settings or disable proxies temporarily.

Final Notes

Since this started suddenly without changes to your environment, the most likely fixes are clearing the cache or reinstalling the Angular CLI. Start with those two first—they resolve most cases like this.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 04:08:01