搭建 React Native 开发环境MAC+Android

参考教程:

​​​​​搭建开发环境 · React Native 中文网欢迎使用 React Native!这篇文档会帮助你搭建基本的 React Native 开发环境。https://www.react-native.cn/docs/environment-setup

踩坑记录:

1.执行npm install -g yarn时候报错

(base) zoes-MacBook-Pro:~ zoe$ sudo npm install -g yarn

> yarn@1.22.18 preinstall /usr/local/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)

npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
npm ERR! dest /usr/local/bin/yarn
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/local/bin/yarn'
npm ERR! File exists: /usr/local/bin/yarn
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zoe/.npm/_logs/2022-04-26T07_29_58_787Z-debug.log

尝试加上--force to overwrite files recklessly,依旧报错

进入/usr/local/bin 目录删除yarn和yarnpkg后重新执行命令,解决

2.执行brew tap homebrew/cask-versions时报错

参考博客:https://www.cnblogs.com/fanstudy/p/13795885.htmlhttps://www.cnblogs.com/fanstudy/p/13795885.html

解决方案:

首先安装homebrew-cask:

git clone https://mirrors.ustc.edu.cn/homebrew-cask.git

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

其次安装homebrew-cask-versions

git clone https://gitee.com/excelsi0r/homebrew-cask-versions.git

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions

3.执行brew install --cask zulu11出错

(base) zoes-MacBook-Pro:~ zoe$ brew install --cask zulu11
Error: Cask 'zulu11' is unavailable: No Cask with this name exists.

解决方案:

直接去官网下载 Zulu.jdk

下载第一个.dmg的即可,下载后打开安装即可

4.执行npx react-native init AwesomeProject时出错

error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./AwesomeProject/ios && pod install".
CocoaPods documentation: https://cocoapods.org/

解决方案 :首先安装一下Xcode(如果你和我一样把Xcode删了>)

然后尝试一下修改cocoapod镜像: 

react-native创建项目遇到的问题及报错和解决方案_崽崽的谷雨的博客-优快云博客

添加ruby镜像时出错,需要更新ruby:

Mac 升级ruby版本_SunshineForU的博客-优快云博客_mac 升级ruby

但是我上面两个方法都没成功

命令行走代理服务器:

https://blog.youkuaiyun.com/weixin_43972437/article/details/118724529

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值