This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
清除 Windows 上的 bundler 缓存
编辑页面
了解在 Windows 上使用 Expo CLI 或 React Native CLI 时,如何清除 Yarn 或 npm 的 bundler 缓存。
需要在 macOS 或 Linux 上清除开发缓存吗?在此查找相关命令。
与你的项目相关联的缓存有很多种,它们可能会阻止你的项目按预期运行。清除缓存有时可以帮助你绕过与过期或损坏数据相关的问题,并且在排查和调试时通常很有用。
Expo CLI 和 Yarn
Terminal
# 使用 Yarn workspaces 时,您可能需要删除每个工作区中的 node_modules- rm -rf node_modules- yarn cache clean- yarn- watchman watch-del-all- del %localappdata%Temphaste-map-*- del %localappdata%Tempmetro-cache- npx expo start --clearExpo CLI 和 npm
Terminal
- rm -rf node_modules- npm 缓存清理 --force- npm install- watchman watch-del-all- del %localappdata%Temphaste-map-*- del %localappdata%Tempmetro-cache- npx expo start --clearReact Native CLI 和 Yarn
Terminal
# 使用 Yarn workspaces 时,你可能需要删除每个 workspace 中的 node_modules- rm -rf node_modules- yarn cache clean- yarn- watchman watch-del-all- del %localappdata%Temphaste-map-*- del %localappdata%Tempmetro-cache- yarn start -- --reset-cacheReact Native CLI 和 npm
Terminal
- rm -rf node_modules- npm cache clean --force- npm install- watchman watch-del-all- del %localappdata%Temphaste-map-*- del %localappdata%Tempmetro-cache- npm start -- --reset-cache这些命令在做什么
在运行你在网上找到的命令之前,先了解它们的作用是个好习惯。下面我们分别解释 Expo CLI、npm 和 Yarn 的每个命令,不过 React Native CLI 中对应的命令具有相同的行为。
| 命令 | 描述 |
|---|---|
del node_modules | 清除项目的所有依赖项 |
yarn cache clean | 清除全局 Yarn 缓存 |
npm cache clean --force | 清除全局 npm 缓存 |
yarn/npm install | 重新安装所有依赖项 |
watchman watch-del-all | 重置 watchman 文件监视器 |
del %localappdata%\Temp/<cache> | 清除指定的打包器/捆绑器缓存文件或目录 |
npx expo start --clear | 重新启动开发服务器并清除 JavaScript 转换缓存 |