美文网首页
React Native入门1(搭建环境)

React Native入门1(搭建环境)

作者: again龙 | 来源:发表于2020-04-14 11:46 被阅读0次

1、安装环境

Mac平台需要的环境

Node, Watchman, React Native command line interface, Xcode.

1)安装Node & Watchman

brew install node

brew install watchman

2)安装yarn命令(可选)

npm install-g yarn--registry=https://registry.npm.taobao.org

配置源

yarn config set registry https://registry.npm.taobao.org-gyarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass-g

2、创建新的本地项目

npx react-native init xxx 

或者可以在此命令后面增加“—version”参数(注意是两个杠)创建指定react版本的项目。例如npx react-native init MyApp --version 0.44.3。注意版本号必须精确到两个小数点

3、运行项目

1)通过npx命令运行

cd AwesomeProject
npx react-native start
npx react-native run-ios

2)通过yarn命令运行(可选)

cd AwesomeProject 
yarn ios

相关文章

网友评论

      本文标题:React Native入门1(搭建环境)

      本文链接:https://www.haomeiwen.com/subject/ioyzmhtx.html