12
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

React-nativeのよくあるエラーを解消するスクリプト

Last updated at Posted at 2019-05-05

概要

React-nativeでエラーが出た時にググると必ず出てくる鉄板の対処方法をまとめたスクリプトを書いた.

リセットしたくなったらこれで一発.

スクリプト

reset.sh
# !/bin/bash

watchman watch-del-all &&
 rm -rf node_modules/ &&
 rm -rf ios/build &&
 npm cache clean --force &&
 npm install &&
 rm -rf $TMPDIR/react-* &&
 rm -rf $TMPDIR/haste-* &&
 rm -rf $TMPDIR/metro-* &&
 rm -rf ~/Library/Developer/Xcode/DerivedData/ 

実行方法

作業ディレクトリで以下のコマンドを実行

sh reset.sh

何をしているか

watchmanのデータを削除

watchman watch-del-all

ノードのパッケージ削除

rm -rf node_modules/

iOSビルドファイル削除

rm -rf ios/build

npmのキャッシュを削除

npm cache clean --force

パッケージの再インストール

npm install

React-nativeの一時データ削除

rm -rf $TMPDIR/react-* 
rm -rf $TMPDIR/haste-* 
rm -rf $TMPDIR/metro-* 

Xcodeの一時データ削除

rm -rf ~/Library/Developer/Xcode/DerivedData/

その他のエラー対処方法

パッケージがReact-nativeのバージョンによって使えたり使えなかったりすることが原因のことがよくあるので,パッケージのバージョンを変えたり,React-nativeのバージョンを変えてみるとうまくいくことが多い.

蛇足:作業ディレクトリ内のパッケージ確認方法

npm list --depth=0

Happy Hacking!

12
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?