参考教程:
踩坑记录:
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