react-native

React Native QUICK STARTをやったらハマった

Building Projects with Native Code

結果から書くと、QuickStartの隣のタブのBuilding Projects with Native Codeをやったらうまくいった。
以下は失敗の記録メモ

install react-native

npm install -g create-react-native-app
create-react-native-app AwesomeProject

errorが表示された

React Nativeはnpm4でしか動作しない模様

*******************************************************************************
ERROR: npm 5 is not supported yet
*******************************************************************************

It looks like you're using npm 5 which was recently released.

Create React Native App doesn't work with npm 5 yet, unfortunately. We
recommend using npm 4 or yarn until some bugs are resolved.

You can follow the known issues with npm 5 at:
https://github.com/npm/npm/issues/16991

*******************************************************************************

リリース一覧 | Node.js

--

Version LTS Date V8 npm NODE_MODULE_VERSION
Node.js7.10.1 2017-07-11 5.5.372.43 4.2.0 51

npmのバージョンを下げる

nodebrew install-binary v7.10.1
nodebrew list
nodebrew use v7.10.1
npm -v

再度

npmのバージョンが変わったからcreate-react-native-appから入れ直し。

npm install -g create-react-native-app
rm -r AwesomeProject
create-react-native-app AwesomeProject

app start

cd AwesomeProject
npm start

再度 error

npm ERR! Darwin 17.4.0
npm ERR! argv "/Users/.nodebrew/node/v7.10.1/bin/node" "/Users/.nodebrew/current/bin/npm" "start"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! AwesomeProject@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the AwesomeProject@0.1.0 start script 'react-native-scripts start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the AwesomeProject package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     react-native-scripts start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs AwesomeProject
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls AwesomeProject
npm ERR! There is likely additional logging output above.

node.jsを最新にしろって・・・
ついでに最新のnodeを入れる

nodebrew install latest
nodebrew use v9.8.0
node -v

npm start

まだダメ

iMac2016:AwesomeProject atsu$ npm start

> AwesomeProject@0.1.0 start AwesomeProject
> react-native-scripts start

14:19:35: 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! AwesomeProject@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the AwesomeProject@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//.npm/_logs/2018-03-21T05_19_35_112Z-debug.log

Start script hangs without error when there are no available inotify watches · Issue #234 · react-community/create-react-native-app

watchman 入れる

brew install watchman

再度 npm start

> react-native-scripts start

14:31:43: Starting packager...
Error: Cannot find module 'is-typedarray'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:470:25)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/atsu/Desktop/react native/AwesomeProject/node_modules/request/request.js:20:20)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)
npm install -g is-typedarray