Expoで初めてシュミレータを立ち上げる際に既にWarningが出ている→npm startで大量ERR

ゴールデンウィーク
キャンプの予定が消え、
ディズニーに行く予定も消え、
暇になってしまった。

ReactNativeやんぞ!
ってことで2400円で買ったった。
www.udemy.com


セクション7の25で詰まった\(^o^)/
iOSアプリの画面が真っ赤っ赤。


結論から言うと、watchmanとflowをHomebrewでインストールしてプロジェクトを再作成すれば解決した(一番下にコマンド有ります。)。

Warningを解決する

よく見たらExpoをインストールしてiOSシュミレーターを立ち上げようと思ったら左下にオレンジ色でissueも出てる。

Warning: You are using npm version 5.6.0. There may be bugs in this version, use it at your own risk. We recommend version latest.

forums.expo.io

他の人もこの問題ではまってるっぽい。
解決策の一つとしてとして、expをダウングレードする方法があるっぽい。

npm install exp@45.0.2 -g

うまくいかない…。


npm startのエラーを解決する

npm startしてねと言われるのでしてみる(Udemyのチュートリアルではしてなかった)。

$ npm start
npm ERR! path /Users/sane/Code/ReactNative/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/sane/Code/ReactNative/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sane/.npm/_logs/2018-04-28T14_13_35_297Z-debug.log

取り敢えずぐぐる
stackoverflow.com

$ npm install -d
$ npm start
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sane/.npm/_logs/2018-04-28T14_18_44_105Z-debug.log

お、jsonは作られたっぽいけど、、、
$ create-react-native-app my-app
のあとcdでmy-appに入ってないわ。。。
はいはい、cdして解決〜と思ったら全然解決してなかった。
そもそもサーバ動いてないってどういうこっちゃ。

$ npm start

> Udemy@0.1.0 start /Users/sane/Code/ReactNative/Udemy
> react-native-scripts start

23:24:45: Unable to start server
See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
  sudo sysctl -w kern.maxfiles=5242880
  sudo sysctl -w kern.maxfilesperproc=524288
        
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Udemy@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the Udemy@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sane/.npm/_logs/2018-04-28T14_24_46_033Z-debug.log

はぁ…。
取り敢えず言われたとおり以下のサイトに行ってみる。
https://git.io/v5vcn
よくわからん。

結論:watchmanとflowをインストールしろ

github.com

watchmanが必要っぽい。
以下のQiitaを参考にする。そもそもインストールが推奨されているらしい。
qiita.com

$ brew install watchman
$ brew install flow
$ create-react-native-app my-react-native-app
$ npm start

今までのアプリだとエラーが出るでプロジェクトを再作成する。
無事iOSアプリの方でも立ち上がった。


UdemyではExpoでプロジェクトを作成してたけど、コマンドで作成する方で行こう。