Hello, React Native

2017-04-25  本文已影响0人  巴依老爷的锅

这个东西最近比较火,我也忍不住拿来研究一番

  1. 安装Node
    brew install node
    设置镜像
    npm config set registry https://registry.npm.taobao.org --global
    npm config set disturl https://npm.taobao.org/dist --global
  2. 安装Yarn, Facebook提供的替代npm的工具,可以加速node模块的下载
    brew install yarn
    设置镜像
    yarn config set registry https://registry.npm.taobao.org --global
    yarn config set disturl https://npm.taobao.org/dist --global
    注意不建议使用npm安装yarn,参见https://yarnpkg.com/lang/en/docs/install/#alternatives-tab
    Note: Installation via npm is generally not recommended. npm is non-deterministic, packages are not signed, and npm does not perform any integrity checks other than a basic SHA1 hash, which is a security risk when installing system-wide apps.
    For these reasons, it is highly recommended that you install Yarn through the installation method best suited to your operating system.
  3. 安装React Native的命令行工具(react-native-cli)
    npm install -g react-native-cli
    4.安装Xcode或者Android Studio
  4. 安装Watchman以及官方推荐的Atom插件Nuclide
    brew install watchman
    Nuclide只能在Atom中起一个server,运行应用还得回到命令行react-native run-xxx

预备工作完成,可以开始创建一个项目了:
react-native init HelloWorld
cd HelloWorld
react-native run-ios 或者 react-native run-android
注意项目创建后名字不能随便改,否则会出错,另外项目不要起名太高端,比如叫ReactNative,这种名字会给自己找麻烦,对,我就找了一回。
还要注意运行安卓之间必须保证有模拟器已经在运行中。

上一篇下一篇

猜你喜欢

热点阅读