React Native 安装步骤和常见问题

2016-03-07  本文已影响2105人  maisie0731

React Native安装步骤

前期准备

  1. 安装nvm
  2. $ nvm install node && nvm alias default node

安装react native

Q&A

1. 启动node server报错

Failed to build DependencyGraph: Cannot read property 'root' of nullTypeError: Cannot read property 'root' of null at index.js:16:60
at tryCallOne (/Users/liying/react_test/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
at /Users/liying/react_test/node_modules/react-native/node_modules/promise/lib/core.js:123:15
at flush (/Users/liying/react_test/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
at doNTCallback0 (node.js:430:9)
at process._tickCallback (node.js:359:13)~
Process terminated. Press <enter> to close the window

解决方案:

  1. $ brew update
  2. $ brew upgrade watchman
    如果在此过程中遇到报错:

Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
sudo chown -R $(whoami):admin /usr/local

则输入:*$ sudo chown -R liying:admin /usr/local *

2. 模拟器运行报错

ReferenceError-Can-t-find-variable-fbBatchedBridge

可能原因:模拟器与js服务器不在同一网段,无法访问服务器。
解决办法:打开模拟器中的settings,wifi设置中选择WiredSSID链接。
如果在真机上,摇一摇调出设置menu,选择Dev Setting,选择Debug server host & port for device,确保真机与电脑在同一网段,输入电脑IP+服务器默认端口号(8081) eg. 10.180.141.23:8081

上一篇下一篇

猜你喜欢

热点阅读