react native 环境搭建时碰到的坑(mac)

react native 环境搭建步骤如下:

1、安装Homebrew


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


2、安装node


brew install node

3、安装react native


npm install -g react-native-cli

4、安装Xcode


去appstore下载安装


5、安装watchman


brew install watchman

6、新建项目


react-native init AwesomeProject

7、跑起来

cd AwesomeProject

react-native run-ios


一、iosAPP打开闪退

1、重新安装node,报错误:

Error: The `brew link` step did not complete successfully

The formula built, but is not symlinked into /usr/local

Could not symlink bin/pkg-config

2、把node卸载干净

sudo npm uninstall npm -g


sudo make uninstall


rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*


ls -laF /usr/local/{lib/node{,/.npm},bin,share/man} | grep npm


find /usr/local/{lib/node,bin} -exec grep -l npm \{\} \; ;


重新执行brew install node。


成功。


安全起见,执行:


sudo chown -R `whoami` /usr/local

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

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

echo prefix=~/.npm-packages >> ~/.npmrc

curl -L https://www.npmjs.com/install.sh | sh

 add the following line to your ~/.bash_profile:

export PATH="$HOME/.npm-packages/bin:$PATH"

source ~/.bash_profile或者重启电脑

现在,您可以重新安装你需要任何包,没有任何问题的。



二、执行brew install watchman时,控制台报错:

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


解决方案:

在终端依次输入以下命令

1、brew uninstall watchman

2、sudo chown -R `whoami` /usr/local

3、brew link --overwrite autoconf

4、brew install watchman

控制台继续报错:

Error: The `brew link` step did not complete successfully

The formula built, but is not symlinked into /usr/local

Could not symlink bin/pcre-config

Target /usr/local/bin/pcre-config

already exists. You may want to remove it:

  rm '/usr/local/bin/pcre-config'




解决方案:

在终端依次输入以下命令

1、brew uninstall watchman

2、sudo chown -R `whoami` /usr/local

3、brew link --overwrite pcre

4、brew install watchman

成功。


三、重新按步骤依次执行,哈哈~成功~
































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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值