(0037) React-Native开发之环境配置步骤和安装使用

来源:互联网 发布:人工智能培训好学吗 编辑:程序博客网 时间:2024/06/05 20:38

参考链接:http://blog.csdn.net/callzjy/article/details/53623124


React-Native环境配置步骤和安装使用:(Mac 10.12.3)


先附上React-Native官方文档中文版:http://wiki.jikexueyuan.com/project/react-native/getting-started.html

好,接下来我们看下安装的过程。


1.安装Homebrew

// a.查看Homebrew 的版本号

$brew -v

// b.如果没有就安装

$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


==> Installation successful! 出现时,安装成功。


遇到

Already up-to-date.

Error: Could not link:

/usr/local/share/man/man1/brew.1


Please delete these paths and run `brew update`.

Error: Could not link:

/usr/local/share/doc/homebrew


Please delete these paths and run `brew update`.


复制路径:  CMD+shift +G 前往文件夹  找到文件,后移除文件。注意备份。

然后

$brew update 

出现Already up-to-date.安装完毕。


2.安装Node

$brew install node

$brew install watchman

Error: You must `brew link autoconf automake` before watchman can be installed

$brew link autoconf automake

$brew install watchman

$brew install flow


3.安装react-native (或者npm install -g yarn react-native-cli

$npm install -g react-native-cli


//查看react-native的版本

$react-native --version

安装成功


4、配置镜像

  1. $npm config set registry https://registry.npm.taobao.org  
  2. $npm config set disturl https://npm.taobao.org/dist  


5.创建RN工程

cd 到你放工程的文件路径

$cd /Users/dev_lzz/Desktop/开发/ReactNative/HelloWorld


最终出现

To run your app on iOS:

   cd /Users/dev_lzz/Desktop/开发/ReactNative/HelloWorld

   react-native run-ios

   - or -

   Open ios/HelloWorld.xcodeproj in Xcode

   Hit the Run button

To run your app on Android:

   cd /Users/dev_lzz/Desktop/开发/ReactNative/HelloWorld

   Have an Android emulator running (quickest way to get started), or a device connected

   react-native run-android

即可大功告成。


6、其他

(1)查看本地的React Native的版本 

$react-native --version  


(2)更新本地的React Native的版本

$npm update -g react-native-cli  


(3)查询react-native的npm包最新版本 

$npm info react-native  


(4)更新项目中的RN

先要进到项目中cd Helloworld的目录  然后

$react-native upgrade





0 0
原创粉丝点击