第一个reactnative项目

1.搭建rn环境
必须安装的依赖有:Node、Watchman 和 React Native 命令行工具
我们推荐使用Homebrew来安装 Node 和 Watchman。在命令行中执行下列命令安装:

安装homebrew

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

中间可能会报错:

error: could not lock config file /usr/local/Homebrew/.git/config: Permission denied
fatal: could not set ‘core.repositoryformatversion’ to ‘0’
Failed during: git init -q

添加权限即可:

sudo chgrp -R admin /usr/local
sudo chmod -R g+w /usr/local

然后安装node,watchman

	brew install node
   brew install watchman

如果丧尽天良报了错,只能卸载homebrew

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

执行完毕会提示有些配置文件需要手动删除,一定要手动删除哦,不然还会扑街

删除文件

rm 文件名  

删除目录

sudo rm -r -f 目录名  

删除成功之后,重新安装homebrew

然后安装node watchman

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

3.去你喜欢的workspace新建项目test喽

react-native init test
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zz白龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值