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

如何清理Angular项目中.angular目录下的构建缓存?

Angular 13+ .angular缓存目录清理方法

从Angular 13.0.0版本开始,项目根目录会自动生成被git默认忽略的.angular目录,该目录下的cache文件夹用于存储项目构建缓存,可通过以下方法清理缓存内容:

方法1:使用Angular CLI官方命令(推荐)

直接在项目根目录执行CLI原生的缓存清理指令即可完成清理:

ng cache clean

如果Angular CLI仅在项目局部安装、未配置全局环境变量,可通过npx调用:

npx ng cache clean

方法2:手动删除缓存目录

直接删除.angular/cache文件夹即可完成缓存清理,不同系统对应终端命令如下:

  • Linux/macOS 终端:
    rm -rf .angular/cache
    
  • Windows CMD命令行:
    rmdir /s /q .angular\cache
    
  • Windows PowerShell:
    Remove-Item -Recurse -Force .angular\cache
    

补充说明:如果需要临时禁用缓存执行构建/开发服务命令,可在原命令后添加--no-cache参数,例如ng build --no-cache、ng serve --no-cache;如果需要永久关闭缓存功能,可在项目angular.json配置文件的cli节点下新增"cache": { "enabled": false }配置项即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.27 02:36:00