Clean react native project

半腔热情 提交于 2021-02-17 14:32:29

问题


How to clean react native project?

Is there any way to clean react native project as we can clean xcode project?

Any help will be appreciated!


回答1:


A react-native Project is about one XCode Project and one Android Project. (for pure js code, there's no need to do clean)

So, what you need would be

Clean XCode Project with

cd ios
xcodebuild clean

And then clean Android Project with

cd android
./gradlew clean

You can simply write a batch file for it.




回答2:


For android project

cd android &&./gradlew clean && cd ../

For iOS project

cd ios && xcodebuild clean && cd ../

If you need build clean again and again then add this scripts in the package.json file like this

scripts: { 
  "clean:android": "cd android && ./gradlew clean && cd ../",
  "clean:ios": "cd ios && xcodebuild clean && cd ../", 
}

Then run for android

yarn clean:android

And run for iOS

yarn clean:ios



回答3:


For Android

cd android
gradlew clean

For IOS

cd ios
xcodebuild clean



回答4:


Delete node modules and

npm ci

react-native link

followed by

react-native start --reset-cache



回答5:


To reset react-native specific cache, run:

npm start -- --reset-cache

if in package.json you have

"scripts": {
  "start": "node node_modules/react-native/local-cli/cli.js start"
}



回答6:


React and node specific cleaning:

Remove node_modules to avoid inconsitence which may appear somehow rarely:

rm -rf node_modules

(reinstall if need with npm or yarn)

Clean npm cache if npm is used

npm cache clean

Clean react temp files:

rm -rf $TMP/react*



回答7:


Clean the Android Project with:

cd android/
gradlew clean



回答8:


this script will clean the Android and IOS build cache, then removes node modules and caches, and reinstall the react native project.

# rm -rf $HOME/.gradle/caches/
cd android && ./gradlew cleanBuildCache
cd ..
cd ios && pod cache clean --all && rm -rf build
cd ..
rm -rf node_modules
yarn cache clean --force
yarn install
cd ios && pod install

To reset the iOS simulator and erase all simulator data, focus on the simulator then go to Hardware -> Erase All Content and Settings

To reset the Android emulator and erase all data, open Android Studio then goes to menu Tools -> AVD Manager, then click the dropdown menu on the selected simulator and click on wipe data.




回答9:


remove android folder run

react-native upgrade

then

react-native run-android


来源:https://stackoverflow.com/questions/48018988/clean-react-native-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!