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

Angular CLI更新后创建/运行项目异常及代理问题技术求助

Hey there, let's work through these two issues step by step to get you back to building Angular apps without headaches!

1. 代理相关问题排查

First, let's rule out proxy-related issues since they often interfere with package installs and Angular CLI operations:

  • 检查系统级代理设置: If you're behind a corporate or local proxy, verify it's configured correctly (on Windows, check Internet Options; on macOS, go to Network settings). Try temporarily disabling the proxy to see if the issue goes away.
  • 清理npm/yarn代理配置: Run these commands to check and clear any proxy settings tied to your package manager:
    # 查看当前代理设置
    npm config get proxy
    npm config get https-proxy
    
    # 若不需要则删除代理配置
    npm config delete proxy
    npm config delete https-proxy
    
  • 验证项目专属代理配置: If you're using a proxy.conf.json in your Angular project, double-check its syntax—common mistakes include typos in target URLs or path rewrites. Make sure it follows the correct Angular proxy format with proper target and path rewrite rules.
2. 解决Angular CLI更新后创建/运行应用异常

Since reinstalling Node and CLI didn't resolve the issue, let's do a deeper clean and ensure version compatibility:

  • 彻底重置CLI:
    1. 卸载全局Angular CLI:
      npm uninstall -g @angular/cli
      
    2. 完全清除npm缓存:
      npm cache clean --force
      
    3. 针对现有Angular项目,删除本地依赖和锁文件:
      rm -rf node_modules package-lock.json  # macOS/Linux系统
      # 或Windows系统执行
      rmdir /s node_modules && del package-lock.json
      
    4. 重新安装与Node版本兼容的稳定版CLI。比如你若使用Node.js 18 LTS(多数用户推荐版本),可以安装Angular CLI 16或17:
      npm install -g @angular/cli@17
      
  • 确保Node.js与CLI版本兼容: Angular CLI对Node.js版本有严格要求,例如:
    • Angular 17需要Node.js 18.13.0+ 或 20.9.0+
    • Angular 16需要Node.js 16.14.0+ 或 18.10.0+
      建议使用nvm(Node版本管理器)来轻松切换Node版本,避免手动重装和版本冲突。
  • 检查权限问题:
    • Windows系统:安装全局包或运行ng命令时,以管理员身份打开终端。
    • macOS/Linux系统:避免使用sudo执行npm安装,可配置npm使用用户专属的全局目录来绕过权限限制。
  • 用全新应用测试: 创建一个全新的Angular项目来隔离问题:
    ng new test-angular-app
    cd test-angular-app
    ng serve
    
    如果错误仍然存在,请分享终端里的具体错误信息(或转录你提供的截图中的关键内容)——这将帮助我们精准定位是依赖冲突、缺失模块还是其他运行时问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 09:43:21