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

升级Angular 6遇npm报错:Refusing to delete,求解决方案

Fixing the "Refusing to delete node_modules/.bin/ng" Error During Angular 5 → 6 Upgrade

Hey there, let's tackle that frustrating error you're running into while upgrading your Angular 5.2 app to Angular 6. That Refusing to delete... message happens because the ng executable in your project's node_modules/.bin directory isn't managed by the new @angular/cli package you're trying to install—probably a leftover from an older CLI version or a misaligned global/local install.

Here's a step-by-step fix:

  • First, remove the conflicting file
    Depending on your operating system, run the appropriate command:

    • For macOS/Linux:
      rm [MyProjectDirectory]/node_modules/.bin/ng
      
    • For Windows (Command Prompt):
      del [MyProjectDirectory]\node_modules\.bin\ng
      
  • Clear the npm cache to avoid residual issues

    npm cache clean --force
    
  • Reinstall the project-level Angular CLI
    Now go back to your project directory and run:

    npm install @angular/cli
    
  • Continue with the official upgrade steps
    Once the CLI installs successfully, proceed with the update command:

    ng update @angular/cli
    

    Then upgrade the Angular core packages to version 6:

    ng update @angular/core
    

If you still run into issues:

If the problem persists, try a full clean reinstall to eliminate any corrupted dependencies:

  • Delete the node_modules folder and package-lock.json file:
    • macOS/Linux:
      rm -rf node_modules package-lock.json
      
    • Windows:
      rmdir /s /q node_modules
      del package-lock.json
      
  • Reinstall all dependencies:
    npm install
    
  • Then repeat the CLI install and update steps above.

That should get you past the file conflict and back on track with your upgrade.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 07:56:12