Automating the cleaning of a React Native Project
npm install react-native-clean-project !https://img.shields.io/github/license/pmadruga/react-native-clean-project.svg


Cleans your React Native project by purging caches and modules, and reinstalling them again.
yarn add -D react-native-clean-project
This module is automatically detected as a plugin by the standard react-native command, adding new sub-commands:
- react-native clean-project-auto - fully automated project state clean: like a freshly-cloned, never-started repo
- react-native clean-project - interactive project state clean: choose types of react-native state to clean
For complete control (including using command-line arguments to non-interactively fine-tune what state is cleaned):
npx react-native-clean-project
Or add it as a script to your package.json
``json`
"scripts": {
"clean": "react-native-clean-project"
}
This is a combination of the commands suggested in the React Native documentation plus others.
| State Type | Command | In clean-project-auto? | Optional? | Default? | Option Flag |rm -rf $TMPDIR/react-*
| ------------------------- | --------------------------------- | ------------------------ | --------- | -------- | ---------------------------- |
| React-native cache | | Yes | No | true | |rm -rf $TMPDIR/metro-*
| Metro bundler cache | | Yes | No | true | |watchman watch-del-all
| Watchman cache | | Yes | No | true | |rm -rf node_modules
| NPM modules | | Yes | Yes | true | --keep-node-modules |yarn cache clean
| Yarn cache | | Yes | Yes | true | --keep-node-modules |yarn install
| Yarn packages | | No | Yes | true | --keep-node-modules |npm cache verify
| NPM cache | | Yes | Yes | true | --keep-node-modules |npm ci
| NPM Install | | Yes | Yes | true | --keep-node-modules |rm -rf ios/build
| iOS build folder | | Yes | Yes | false | --remove-iOS-build |rm -rf ios/Pods
| iOS pods folder | | Yes | Yes | false | --remove-iOS-pods |pod cache clean --all
| system iOS pods cache | | Yes | Yes | true | --keep-system-iOS-pods-cache |rm -rf ~/.cocoapods
| user iOS pods cache | | Yes | Yes | true | --keep-user-iOS-pods-cache |rm -rf android/build
| Android build folder | | Yes | Yes | false | --remove-android-build |(cd android && ./gradlew clean)
| Android clean project | | Yes | Yes | false | --clean-android-project |brew update && brew upgrade
| Brew package | | No | Yes | true | --keep-brew |pod update
| Pod packages | | No | Yes | true | --keep-pods |
Example: npx react-native-clean-project --remove-iOS-build
You can also reset the Metro bundler cache when starting with react-native start --reset-cache`
This library does not support windows. PR's are welcome.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Pedro Madruga - twitter
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details