初始化ReactNative-项目2018-09-25

2018-09-25  本文已影响16人  超级小学生1
  react-native init projectName

如果没有指定版本号,则默认为最新版本。
指定版本号方式

 react-native init projectName --version 0.44.3

依赖

Node(版本大于8.3), Python2, JDK(必须是8)
Node:https://nodejs.org/en/
Python2:https://www.python.org/
JDK:https://www.oracle.com/technetwork/java/javase/downloads/index.html (注意,要选对版本)
Node自带npm包管理工具,接下来设置镜像

  npm config set registry https://registry.npm.taobao.org --global
  npm config set disturl https://npm.taobao.org/dist --global

Yarn、React Native 的命令行工具(react-native-cli)

Yarn是 Facebook 提供的替代 npm 的工具,可以加速 node 模块的下载。React Native 的命令行工具用于执行创建、初始化、更新项目、运行打包服务(packager)等任务。

npm install -g yarn react-native-cli

安装完 yarn 后同理也要设置镜像源:

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

安装完 yarn 之后就可以用 yarn 代替 npm 了,例如用yarn代替npm install命令,用yarn add 某第三方库名代替npm install 某第三方库名。

yarn和npm区别(别人整理的):

https://blog.csdn.net/qiansg123/article/details/80129453

上一篇 下一篇

猜你喜欢

热点阅读