清除 Windows 上的打包程序缓存

了解如何在 Windows 上使用 Expo CLI 或 React Native CLI 时清除 Yarn 或 npm 的打包器缓存。


需要在 macOS 或 Linux 上清除开发缓存吗?在这里找到相关命令。

你的项目有许多不同的缓存,这些缓存可能会阻止你的项目按预期运行。清除缓存有时可以帮助你解决与陈旧或损坏数据相关的问题,并且在排查和调试时通常很有用。

🌐 There are a number of different caches associated with your project that can prevent your project from running as intended. Clearing a cache sometimes can help you work around issues related to stale or corrupt data and is often useful when troubleshooting and debugging.

Expo CLI 和 Yarn

🌐 Expo CLI and Yarn

Terminal
# With Yarn workspaces, you may need to delete node_modules in each workspace
rm -rf node_modules

yarn cache clean

yarn

watchman watch-del-all

del %localappdata%Temphaste-map-*

del %localappdata%Tempmetro-cache

npx expo start --clear

Expo CLI 和 npm

🌐 Expo CLI and npm

Terminal
rm -rf node_modules

npm cache clean --force

npm install

watchman watch-del-all

del %localappdata%Temphaste-map-*

del %localappdata%Tempmetro-cache

npx expo start --clear

React Native CLI 和 Yarn

🌐 React Native CLI and Yarn

Terminal
# With Yarn workspaces, you may need to delete node_modules in each workspace
rm -rf node_modules

yarn cache clean

yarn

watchman watch-del-all

del %localappdata%Temphaste-map-*

del %localappdata%Tempmetro-cache

yarn start -- --reset-cache

React Native CLI 和 npm

🌐 React Native CLI and 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

这些命令在做什么

🌐 What these commands are doing

在运行互联网找到的命令之前,先理解它们是一个好习惯。我们在下面解释了 Expo CLI、npm 和 Yarn 的每个命令,但相应的 React Native CLI 命令的行为是相同的。

🌐 It is a good habit to understand commands you find on the internet before you run them. We explain each command below for Expo CLI, npm, and Yarn, but the corresponding commands React Native CLI have the same behavior.

命令描述
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 转换缓存