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

执行ng build报错未依赖@angular/core,npm install遇EEXIST错误求助

Fixing Your Angular Build & npm Installation Errors

Let's break down and fix these two issues one by one—starting with the blocking npm error first, then addressing the missing @angular/core dependency.

1. Resolve the npm ERR! code EEXIST Error

This error pops up because the ng command file at /usr/local/bin/ng already exists, and npm can't overwrite it during the global CLI installation. Here's how to clear this conflict:

  • First, delete the existing ng file to make space for the fresh installation:
    sudo rm /usr/local/bin/ng
    
  • Next, clear npm's cache to get rid of any corrupted or outdated cached files that might cause issues:
    npm cache clean --force
    
  • Since your Node.js version is v9.10.1 (which is older), you'll need a compatible Angular CLI version—newer CLI releases won't play nice with Node v9. Install Angular CLI 7.x (the latest stable version that supports Node v9):
    npm install -g @angular/cli@7.3.9
    
  • Verify the installation worked by checking the CLI version:
    ng --version
    

2. Fix the "You seem to not be depending on '@angular/core'" Error

This error means your project's local dependencies are either missing, corrupted, or @angular/core isn't properly listed in your package.json. Let's fix that:

  • Navigate to your project's root directory first.
  • Delete the local node_modules folder and package-lock.json file to wipe out any corrupted dependency data:
    rm -rf node_modules package-lock.json
    
  • Reinstall all local project dependencies from scratch:
    npm install
    
  • If @angular/core still doesn't show up in your package.json after reinstalling, manually add it (match the version to your Angular CLI—for CLI 7.x, use Angular core 7.x):
    npm install @angular/core@7.2.16 --save
    
  • Finally, try building your project again:
    ng build
    

A quick heads-up: Node.js v9 is no longer supported, so if you can spare the time, upgrading to a newer LTS version (like Node 14 or 16) will help avoid future compatibility headaches. But the steps above should get your current setup working smoothly.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 07:41:09