[{"data":1,"prerenderedAt":58},["ShallowReactive",2],{"blog-zh-clean-project-build-artifacts":3},{"meta":4,"html":14,"headings":15,"raw":57},{"title":5,"description":6,"topic":7,"date":8,"author":9,"icons":10},"旧项目的 node_modules、target、build 目录怎么批量清理","找出旧项目里可以重新生成的依赖和构建目录，用命令或浣熊管家批量清理，同时避开虚拟环境和被 Git 跟踪的文件。","developer-cleanup","2026-10-29","浣熊管家团队",[11,12,13],"folder-x","code","scrub-brush","\u003Cp>打开一个旧项目算一下就会发现，源码可能只有几十 MB，\u003Ccode>node_modules\u003C\u002Fcode>、Rust 的 \u003Ccode>target\u003C\u002Fcode>、Gradle 的 \u003Ccode>build\u003C\u002Fcode> 却动辄几百 MB 到几 GB。项目一多，这些能重新生成的目录就成了磁盘里最大的一块。下面帮你判断哪些目录可以删、怎么用命令批量找出来，以及用浣熊管家批量清理时它会怎样保护你的项目。\u003C\u002Fp>\n\u003Ch2 id=\"what-can-be-regenerated\">\u003Ca class=\"heading-anchor\" href=\"#what-can-be-regenerated\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>哪些目录可以重新生成\u003C\u002Fh2>\n\u003Cdiv class=\"table-wrap\">\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>生态\u003C\u002Fth>\u003Cth>常见目录\u003C\u002Fth>\u003Cth>恢复方法\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>Node.js\u003C\u002Ftd>\u003Ctd>\u003Ccode>node_modules\u003C\u002Fcode>、\u003Ccode>.next\u002Fcache\u003C\u002Fcode>、\u003Ccode>.nuxt\u003C\u002Fcode>、\u003Ccode>.turbo\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>npm ci\u003C\u002Fcode>、\u003Ccode>pnpm install\u003C\u002Fcode> 或 \u003Ccode>yarn install\u003C\u002Fcode>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Rust\u003C\u002Ftd>\u003Ctd>\u003Ccode>target\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>cargo build\u003C\u002Fcode>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Gradle、Android\u003C\u002Ftd>\u003Ctd>\u003Ccode>build\u003C\u002Fcode>、\u003Ccode>.gradle\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>重新构建\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Maven\u003C\u002Ftd>\u003Ctd>\u003Ccode>target\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>重新构建\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Swift Package\u003C\u002Ftd>\u003Ctd>\u003Ccode>.build\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>swift build\u003C\u002Fcode>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>CocoaPods\u003C\u002Ftd>\u003Ctd>\u003Ccode>Pods\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>pod install\u003C\u002Fcode>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Flutter、Dart\u003C\u002Ftd>\u003Ctd>\u003Ccode>build\u003C\u002Fcode>、\u003Ccode>.dart_tool\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>flutter pub get\u003C\u002Fcode> 后重新构建\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Python\u003C\u002Ftd>\u003Ctd>\u003Ccode>__pycache__\u003C\u002Fcode>、\u003Ccode>.pytest_cache\u003C\u002Fcode>、\u003Ccode>.mypy_cache\u003C\u002Fcode>、\u003Ccode>.ruff_cache\u003C\u002Fcode>、\u003Ccode>.tox\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>工具运行时自动生成\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>PHP\u003C\u002Ftd>\u003Ctd>\u003Ccode>vendor\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>composer install\u003C\u002Fcode>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>.NET\u003C\u002Ftd>\u003Ctd>\u003Ccode>bin\u003C\u002Fcode>、\u003Ccode>obj\u003C\u002Fcode>\u003C\u002Ftd>\u003Ctd>\u003Ccode>dotnet build\u003C\u002Fcode>\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003C\u002Fdiv>\n\u003Cp>能原样恢复的前提是项目里有锁文件，例如 \u003Ccode>package-lock.json\u003C\u002Fcode>、\u003Ccode>pnpm-lock.yaml\u003C\u002Fcode>、\u003Ccode>yarn.lock\u003C\u002Fcode>、\u003Ccode>Cargo.lock\u003C\u002Fcode>、\u003Ccode>Podfile.lock\u003C\u002Fcode>、\u003Ccode>composer.lock\u003C\u002Fcode>，这样重新安装得到的版本和删除前一致。\u003C\u002Fp>\n\u003Ch2 id=\"risks\">\u003Ca class=\"heading-anchor\" href=\"#risks\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>删除前的风险\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>\u003Cstrong>虚拟环境要先记下依赖\u003C\u002Fstrong>：Python 的 \u003Ccode>.venv\u003C\u002Fcode>、\u003Ccode>venv\u003C\u002Fcode> 可以重建，前提是 \u003Ccode>requirements.txt\u003C\u002Fcode> 或锁文件记录了依赖。没有记录时先导出：\u003Ccode>pip freeze &gt; requirements.txt\u003C\u002Fcode>。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>有些构建目录里有手写文件\u003C\u002Fstrong>：个别项目会把配置、密钥或手写脚本放进 \u003Ccode>build\u003C\u002Fcode>、\u003Ccode>target\u003C\u002Fcode>，甚至提交进 Git。删除前看一眼目录里有没有被跟踪的文件。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>老项目可能装不回来\u003C\u002Fstrong>：依赖的包可能已被下架，旧版工具链也可能装不上。还要维护的老项目，先确认能重新安装再删。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>pnpm 项目释放得少\u003C\u002Fstrong>：pnpm 项目的 \u003Ccode>node_modules\u003C\u002Fcode> 和全局存储共用数据块，删掉后实际释放的空间可能比显示的小。\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"manual-cleanup\">\u003Ca class=\"heading-anchor\" href=\"#manual-cleanup\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>手动批量清理\u003C\u002Fh2>\n\u003Ch3 id=\"find-them\">\u003Ca class=\"heading-anchor\" href=\"#find-them\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>先找出来\u003C\u002Fh3>\n\u003Cp>假设你的项目都在 \u003Ccode>~\u002FProjects\u003C\u002Fcode> 下。下面的命令列出所有 \u003Ccode>node_modules\u003C\u002Fcode> 和 \u003Ccode>target\u003C\u002Fcode> 目录及其大小，\u003Ccode>-prune\u003C\u002Fcode> 让 \u003Ccode>find\u003C\u002Fcode> 不再进入这些目录内部，速度会快很多：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\">find ~\u002FProjects -type d \\( -name node_modules -o -name target \\) -prune -print0 \\\n  | xargs -0 du -sh 2&gt;\u002Fdev\u002Fnull | sort -h\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>想只看很久没动过的项目，可以加上时间条件。\u003Ccode>node_modules\u003C\u002Fcode> 目录的修改时间大致对应最后一次安装依赖的时间，只能作参考：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\"># 列出 90 天内没有重新安装过依赖的 node_modules\nfind ~\u002FProjects -type d -name node_modules -prune -mtime +90 -print\n# 确认清单无误后再删除，rm -rf 不经过废纸篓\nfind ~\u002FProjects -type d -name node_modules -prune -mtime +90 -exec rm -rf {} +\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3 id=\"tool-commands\">\u003Ca class=\"heading-anchor\" href=\"#tool-commands\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>用工具自带的清理命令\u003C\u002Fh3>\n\u003Cp>在单个项目里，优先用工具自己的命令，它们知道哪些文件是自己生成的：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\">cargo clean            # 删除 Rust 项目的 target\n.\u002Fgradlew clean        # 删除 Gradle 项目的构建输出\nmvn clean              # 删除 Maven 项目的 target\nflutter clean          # 删除 Flutter 项目的 build 和 .dart_tool\nswift package reset    # 删除 Swift Package 的 .build\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3 id=\"git-clean\">\u003Ca class=\"heading-anchor\" href=\"#git-clean\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>用 Git 预览被忽略的文件\u003C\u002Fh3>\n\u003Cp>如果项目用 Git 管理，\u003Ccode>.gitignore\u003C\u002Fcode> 里列的大多是能重新生成的内容。\u003Ccode>git clean -X\u003C\u002Fcode> 只删除被忽略的文件，先用 \u003Ccode>-n\u003C\u002Fcode> 预览：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\"># 预览：列出将被删除的被忽略文件和目录\ngit clean -ndX\n# 确认清单无误后再执行\ngit clean -fdX\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"callout callout-warning\">\u003Cp class=\"callout-title\">注意\u003C\u002Fp>\u003Cp>\u003Ccode>.env\u003C\u002Fcode>、本地配置和编辑器设置通常也在 \u003Ccode>.gitignore\u003C\u002Fcode> 里。预览清单中出现这些文件时，先把它们移走，或者改用前面的 \u003Ccode>find\u003C\u002Fcode> 命令只删指定目录。\u003C\u002Fp>\n\u003C\u002Fdiv>\u003Ch2 id=\"washbear\">\u003Ca class=\"heading-anchor\" href=\"#washbear\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>用浣熊管家批量清理\u003C\u002Fh2>\n\u003Cp>浣熊管家的\u003Ca href=\"\u002Fdocs\u002Fdeep-clean\">深度清理\u003C\u002Fa>把这类目录归在 \u003Cstrong>项目构建产物\u003C\u002Fstrong> 类别，覆盖三十多种工具和框架，按生态分成 \u003Cstrong>Node.js 构建产物\u003C\u002Fstrong>、\u003Cstrong>Rust 构建产物\u003C\u002Fstrong>、\u003Cstrong>Python 构建产物\u003C\u002Fstrong>、\u003Cstrong>Gradle 构建产物\u003C\u002Fstrong> 等条目。它通过 \u003Ccode>package.json\u003C\u002Fcode>、\u003Ccode>Cargo.toml\u003C\u002Fcode>、\u003Ccode>pom.xml\u003C\u002Fcode>、\u003Ccode>Podfile\u003C\u002Fcode> 这类标志文件识别项目，只列出对应工具会生成的目录。展开条目可以看到每个目录的路径、大小、文件数和最近修改时间，并逐个勾选。\u003C\u002Fp>\n\u003Cp>这一类不会被 \u003Cstrong>智能推荐\u003C\u002Fstrong> 预先勾选，也不按时间自动筛选，清哪个项目由你决定。\u003C\u002Fp>\n\u003Ch3 id=\"where-it-looks\">\u003Ca class=\"heading-anchor\" href=\"#where-it-looks\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>浣熊管家会去哪里找项目\u003C\u002Fh3>\n\u003Cul>\n\u003Cli>\u003Cstrong>标准扫描\u003C\u002Fstrong>：查找个人文件夹下的各个文件夹（隐藏文件夹和资源库等应用数据目录除外），并按项目文件夹的修改时间只保留最近的一批项目，目前最多 96 个。项目很多时，很久没动过的项目可能不在结果里。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>选择磁盘\u003C\u002Fstrong>：系统盘始终扫描，还可以勾选外接磁盘等其他磁盘，在其中查找项目，不受上面的数量限制。整理旧项目时建议用这种方式。\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>桌面、文稿和下载文件夹受 macOS 隐私保护，如果你拒绝了访问，这些位置会被跳过。想保护某个项目，把它的文件夹加到 \u003Cstrong>设置 → 扫描与分析 → 扫描排除\u003C\u002Fstrong> 的 \u003Cstrong>指定路径\u003C\u002Fstrong> 中，路径排除对项目构建产物生效。\u003C\u002Fp>\n\u003Ch3 id=\"protections\">\u003Ca class=\"heading-anchor\" href=\"#protections\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>自动跳过的内容\u003C\u002Fh3>\n\u003Cul>\n\u003Cli>构建目录里有被 Git 跟踪的文件、\u003Ccode>.git\u003C\u002Fcode> 目录或 \u003Ccode>*-keypair.json\u003C\u002Fcode> 这类密钥文件时，浣熊管家不会清理它，结果中显示 \u003Cstrong>无法完整读取，未加入清理\u003C\u002Fstrong>。项目位于 Git 仓库中、而这台 Mac 上找不到 Git 时，同样不清理。\u003C\u002Fli>\n\u003Cli>清理前会重新检查项目和目录，条件不再满足的目录会被跳过。\u003C\u002Fli>\n\u003Cli>Python 的 \u003Ccode>.venv\u003C\u002Fcode>、\u003Ccode>venv\u003C\u002Fcode> 不在清理范围内，\u003Cstrong>Python 构建产物\u003C\u002Fstrong> 只包括 \u003Ccode>__pycache__\u003C\u002Fcode>、\u003Ccode>.pytest_cache\u003C\u002Fcode> 这类工具缓存。Node.js 项目的 \u003Ccode>dist\u003C\u002Fcode>、\u003Ccode>build\u003C\u002Fcode> 输出目录也不在其中。\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>清理会直接删除，不进入废纸篓，结果记录在\u003Ca href=\"\u002Fdocs\u002Fgetting-started#history\">操作历史\u003C\u002Fa>中。全局的 npm、pnpm 缓存是另一类内容，见 \u003Ca href=\"\u002Fblog\u002Fclear-js-package-caches\">npm、pnpm、Yarn 缓存的清理方法\u003C\u002Fa>；Xcode 的 DerivedData 见 \u003Ca href=\"\u002Fblog\u002Fclear-xcode-storage\">Xcode 存储清理\u003C\u002Fa>。\u003C\u002Fp>\n\u003Cp>想先看看旧项目里有多少可清理的内容，可以\u003Ca href=\"\u002Fdownload\">下载浣熊管家\u003C\u002Fa>扫描一次，扫描本身不会删除任何内容。下面的演示窗口使用示例数据，其中的条目和数值仅作示意。\u003C\u002Fp>\n\u003C!--demo:deepClean-->\u003Ch2 id=\"faq\">\u003Ca class=\"heading-anchor\" href=\"#faq\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>常见问题\u003C\u002Fh2>\n\u003Ch3 id=\"faq-restore\">\u003Ca class=\"heading-anchor\" href=\"#faq-restore\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>删除 node_modules 后怎么恢复？\u003C\u002Fh3>\n\u003Cp>在项目目录里运行安装命令即可，例如 \u003Ccode>npm ci\u003C\u002Fcode>、\u003Ccode>pnpm install\u003C\u002Fcode> 或 \u003Ccode>yarn install\u003C\u002Fcode>。有 \u003Ccode>package-lock.json\u003C\u002Fcode> 时，\u003Ccode>npm ci\u003C\u002Fcode> 会严格按锁文件安装。\u003C\u002Fp>\n\u003Ch3 id=\"faq-source-code\">\u003Ca class=\"heading-anchor\" href=\"#faq-source-code\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>浣熊管家会删到源码吗？\u003C\u002Fh3>\n\u003Cp>不会。它只删除规则中列出的目录，这些目录必须位于能识别的项目里，含有被 Git 跟踪文件的目录会被跳过。\u003C\u002Fp>\n\u003Ch3 id=\"faq-external-drive\">\u003Ca class=\"heading-anchor\" href=\"#faq-external-drive\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>外接硬盘上的项目能清理吗？\u003C\u002Fh3>\n\u003Cp>能。点 \u003Cstrong>开始扫描\u003C\u002Fstrong> 右侧的箭头，选择 \u003Cstrong>选择磁盘\u003C\u002Fstrong>，勾选那块磁盘后开始扫描。\u003C\u002Fp>\n",[16,20,23,26,30,33,36,39,42,45,48,51,54],{"depth":17,"id":18,"text":19},2,"what-can-be-regenerated","哪些目录可以重新生成",{"depth":17,"id":21,"text":22},"risks","删除前的风险",{"depth":17,"id":24,"text":25},"manual-cleanup","手动批量清理",{"depth":27,"id":28,"text":29},3,"find-them","先找出来",{"depth":27,"id":31,"text":32},"tool-commands","用工具自带的清理命令",{"depth":27,"id":34,"text":35},"git-clean","用 Git 预览被忽略的文件",{"depth":17,"id":37,"text":38},"washbear","用浣熊管家批量清理",{"depth":27,"id":40,"text":41},"where-it-looks","浣熊管家会去哪里找项目",{"depth":27,"id":43,"text":44},"protections","自动跳过的内容",{"depth":17,"id":46,"text":47},"faq","常见问题",{"depth":27,"id":49,"text":50},"faq-restore","删除 node_modules 后怎么恢复？",{"depth":27,"id":52,"text":53},"faq-source-code","浣熊管家会删到源码吗？",{"depth":27,"id":55,"text":56},"faq-external-drive","外接硬盘上的项目能清理吗？","\n打开一个旧项目算一下就会发现，源码可能只有几十 MB，`node_modules`、Rust 的 `target`、Gradle 的 `build` 却动辄几百 MB 到几 GB。项目一多，这些能重新生成的目录就成了磁盘里最大的一块。下面帮你判断哪些目录可以删、怎么用命令批量找出来，以及用浣熊管家批量清理时它会怎样保护你的项目。\n\n## 哪些目录可以重新生成 {#what-can-be-regenerated}\n\n| 生态 | 常见目录 | 恢复方法 |\n| --- | --- | --- |\n| Node.js | `node_modules`、`.next\u002Fcache`、`.nuxt`、`.turbo` | `npm ci`、`pnpm install` 或 `yarn install` |\n| Rust | `target` | `cargo build` |\n| Gradle、Android | `build`、`.gradle` | 重新构建 |\n| Maven | `target` | 重新构建 |\n| Swift Package | `.build` | `swift build` |\n| CocoaPods | `Pods` | `pod install` |\n| Flutter、Dart | `build`、`.dart_tool` | `flutter pub get` 后重新构建 |\n| Python | `__pycache__`、`.pytest_cache`、`.mypy_cache`、`.ruff_cache`、`.tox` | 工具运行时自动生成 |\n| PHP | `vendor` | `composer install` |\n| .NET | `bin`、`obj` | `dotnet build` |\n\n能原样恢复的前提是项目里有锁文件，例如 `package-lock.json`、`pnpm-lock.yaml`、`yarn.lock`、`Cargo.lock`、`Podfile.lock`、`composer.lock`，这样重新安装得到的版本和删除前一致。\n\n## 删除前的风险 {#risks}\n\n- **虚拟环境要先记下依赖**：Python 的 `.venv`、`venv` 可以重建，前提是 `requirements.txt` 或锁文件记录了依赖。没有记录时先导出：`pip freeze > requirements.txt`。\n- **有些构建目录里有手写文件**：个别项目会把配置、密钥或手写脚本放进 `build`、`target`，甚至提交进 Git。删除前看一眼目录里有没有被跟踪的文件。\n- **老项目可能装不回来**：依赖的包可能已被下架，旧版工具链也可能装不上。还要维护的老项目，先确认能重新安装再删。\n- **pnpm 项目释放得少**：pnpm 项目的 `node_modules` 和全局存储共用数据块，删掉后实际释放的空间可能比显示的小。\n\n## 手动批量清理 {#manual-cleanup}\n\n### 先找出来 {#find-them}\n\n假设你的项目都在 `~\u002FProjects` 下。下面的命令列出所有 `node_modules` 和 `target` 目录及其大小，`-prune` 让 `find` 不再进入这些目录内部，速度会快很多：\n\n```bash\nfind ~\u002FProjects -type d \\( -name node_modules -o -name target \\) -prune -print0 \\\n  | xargs -0 du -sh 2>\u002Fdev\u002Fnull | sort -h\n```\n\n想只看很久没动过的项目，可以加上时间条件。`node_modules` 目录的修改时间大致对应最后一次安装依赖的时间，只能作参考：\n\n```bash\n# 列出 90 天内没有重新安装过依赖的 node_modules\nfind ~\u002FProjects -type d -name node_modules -prune -mtime +90 -print\n# 确认清单无误后再删除，rm -rf 不经过废纸篓\nfind ~\u002FProjects -type d -name node_modules -prune -mtime +90 -exec rm -rf {} +\n```\n\n### 用工具自带的清理命令 {#tool-commands}\n\n在单个项目里，优先用工具自己的命令，它们知道哪些文件是自己生成的：\n\n```bash\ncargo clean            # 删除 Rust 项目的 target\n.\u002Fgradlew clean        # 删除 Gradle 项目的构建输出\nmvn clean              # 删除 Maven 项目的 target\nflutter clean          # 删除 Flutter 项目的 build 和 .dart_tool\nswift package reset    # 删除 Swift Package 的 .build\n```\n\n### 用 Git 预览被忽略的文件 {#git-clean}\n\n如果项目用 Git 管理，`.gitignore` 里列的大多是能重新生成的内容。`git clean -X` 只删除被忽略的文件，先用 `-n` 预览：\n\n```bash\n# 预览：列出将被删除的被忽略文件和目录\ngit clean -ndX\n# 确认清单无误后再执行\ngit clean -fdX\n```\n\n> [!WARNING]\n> `.env`、本地配置和编辑器设置通常也在 `.gitignore` 里。预览清单中出现这些文件时，先把它们移走，或者改用前面的 `find` 命令只删指定目录。\n\n## 用浣熊管家批量清理 {#washbear}\n\n浣熊管家的[深度清理](\u002Fdocs\u002Fdeep-clean)把这类目录归在 **项目构建产物** 类别，覆盖三十多种工具和框架，按生态分成 **Node.js 构建产物**、**Rust 构建产物**、**Python 构建产物**、**Gradle 构建产物** 等条目。它通过 `package.json`、`Cargo.toml`、`pom.xml`、`Podfile` 这类标志文件识别项目，只列出对应工具会生成的目录。展开条目可以看到每个目录的路径、大小、文件数和最近修改时间，并逐个勾选。\n\n这一类不会被 **智能推荐** 预先勾选，也不按时间自动筛选，清哪个项目由你决定。\n\n### 浣熊管家会去哪里找项目 {#where-it-looks}\n\n- **标准扫描**：查找个人文件夹下的各个文件夹（隐藏文件夹和资源库等应用数据目录除外），并按项目文件夹的修改时间只保留最近的一批项目，目前最多 96 个。项目很多时，很久没动过的项目可能不在结果里。\n- **选择磁盘**：系统盘始终扫描，还可以勾选外接磁盘等其他磁盘，在其中查找项目，不受上面的数量限制。整理旧项目时建议用这种方式。\n\n桌面、文稿和下载文件夹受 macOS 隐私保护，如果你拒绝了访问，这些位置会被跳过。想保护某个项目，把它的文件夹加到 **设置 → 扫描与分析 → 扫描排除** 的 **指定路径** 中，路径排除对项目构建产物生效。\n\n### 自动跳过的内容 {#protections}\n\n- 构建目录里有被 Git 跟踪的文件、`.git` 目录或 `*-keypair.json` 这类密钥文件时，浣熊管家不会清理它，结果中显示 **无法完整读取，未加入清理**。项目位于 Git 仓库中、而这台 Mac 上找不到 Git 时，同样不清理。\n- 清理前会重新检查项目和目录，条件不再满足的目录会被跳过。\n- Python 的 `.venv`、`venv` 不在清理范围内，**Python 构建产物** 只包括 `__pycache__`、`.pytest_cache` 这类工具缓存。Node.js 项目的 `dist`、`build` 输出目录也不在其中。\n\n清理会直接删除，不进入废纸篓，结果记录在[操作历史](\u002Fdocs\u002Fgetting-started#history)中。全局的 npm、pnpm 缓存是另一类内容，见 [npm、pnpm、Yarn 缓存的清理方法](\u002Fblog\u002Fclear-js-package-caches)；Xcode 的 DerivedData 见 [Xcode 存储清理](\u002Fblog\u002Fclear-xcode-storage)。\n\n想先看看旧项目里有多少可清理的内容，可以[下载浣熊管家](\u002Fdownload)扫描一次，扫描本身不会删除任何内容。下面的演示窗口使用示例数据，其中的条目和数值仅作示意。\n\n::demo deepClean\n\n## 常见问题 {#faq}\n\n### 删除 node_modules 后怎么恢复？ {#faq-restore}\n\n在项目目录里运行安装命令即可，例如 `npm ci`、`pnpm install` 或 `yarn install`。有 `package-lock.json` 时，`npm ci` 会严格按锁文件安装。\n\n### 浣熊管家会删到源码吗？ {#faq-source-code}\n\n不会。它只删除规则中列出的目录，这些目录必须位于能识别的项目里，含有被 Git 跟踪文件的目录会被跳过。\n\n### 外接硬盘上的项目能清理吗？ {#faq-external-drive}\n\n能。点 **开始扫描** 右侧的箭头，选择 **选择磁盘**，勾选那块磁盘后开始扫描。\n",1793257450399]