注:以下步骤在终端中完成
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install node
有可能会出现以下错误:
Error: The following directories are not writable by your user:
/usr/local/etc/bash_completion.d
/usr/local/lib/pkgconfig
/usr/local/share/info
/usr/local/share/locale
/usr/local/share/man/man3
/usr/local/share/man/man8
针对以上错误:
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
npm install -g yarn react-native-cli
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
记得要在xcode->preferences->locations里把command line tools选上
xcode-select —install
出现提示直接安装即可
brew install watchman
react-native init AwesomeProject
react-native run-ios
注:安装的node版本过高,可安装node指定版本