搭建react-native开发环境(iOS)

注:以下步骤在终端中完成


1.安装home-brew

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

2.安装node

brew install node 

有可能会出现以下错误:

Error: The following directories are not writable by your user:

/usr/local/etc/bash_completion.d

/usr/local/lib/pkgconfig

/usr/local/share/info

/usr/local/share/locale

/usr/local/share/man/man3

/usr/local/share/man/man8

针对以上错误:

  • 改变文件拥有者:sudo chown -R $(whoami) /usr/local
  • 继续安装:brew install node

3.设置npm镜像

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

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

4.安装yarn, react-native-cli

npm install -g yarn react-native-cli 

5.设置yarn镜像源 

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

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

6.安装Xcode:(App Store里直接安装)

记得要在xcode->preferences->locations里把command line tools选上

7.安装Xcode命令行工具:

xcode-select —install

出现提示直接安装即可

8.安装watchman

brew install watchman

9.初始化一个项目: 

react-native init AwesomeProject

10.运行

react-native run-ios 


注:安装的node版本过高,可安装node指定版本

  • 安装n模块:sudo npm i -g n --force
  • 安装指定版本或稳定版本:n 10.0.0/stable 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值