安裝nvm
nvm:node版本管理(Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
可能出現(xiàn)githubusercontent.com
無(wú)法訪問(wèn)
直接在github將nvm代碼下載下來(lái)瞬欧,然后進(jìn)入目錄執(zhí)行sh install.sh
進(jìn)行安裝
終端輸入vim ~/.zshrc
,添加環(huán)境變量
# nvm環(huán)境變量钦奋,用于node版本切換
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completio^M
重啟終端坦敌,使用nvm -v
查看版本
常用命令
# 查看可用的node版本列表
nvm list
# 下載需要的node版本
nvm install 14.19.1 #下載14.19.1
# 使用14.19.1版本
nvm use 14.19.1
# 查看node版本
node -v
切換到對(duì)應(yīng)的node版本又可以開(kāi)心的跑項(xiàng)目了
安裝Node
Node直接下載穩(wěn)定版本安裝辞友,自帶npm
npm:node軟件包管理(Node Package Management)
npm國(guó)外鏡像下載很慢,更換鏡像地址
#更換鏡像地址
npm config set registry https://registry.npm.taobao.org
#驗(yàn)證是否成功
npm config get registry
安裝CocoaPods
使用Ruby安裝可能會(huì)出現(xiàn)權(quán)限問(wèn)題覆醇,無(wú)法成功安裝
推薦使用Homebrew來(lái)安裝CocoaPods妆够,繞過(guò)權(quán)限問(wèn)題
安裝brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
使用brew doctor
檢查是否安裝成功
安裝ruby
# 安裝
brew install ruby
# 查看版本
ruby -v
# 結(jié)果:ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
配置ruby環(huán)境
配置環(huán)境Path,使Brew安裝的Ruby調(diào)用優(yōu)先于系統(tǒng)的Ruby
終端輸入vim ~/.zshrc
apple芯片添加以下環(huán)境變量
if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
export PATH=/opt/homebrew/opt/ruby/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi
intel芯片添加以下環(huán)境變量
if [ -d "/usr/local/opt/ruby/bin" ]; then
export PATH=/usr/local/opt/ruby/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi
更換RubyGems鏡像
RubyGems國(guó)外鏡像訪問(wèn)巨慢迎膜,所以切換到國(guó)內(nèi)鏡像就非常順暢了
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem sources -l
通過(guò)brew安裝Cocoapods
# 安裝Cocoapods
brew install cocoapods
# 檢查版本
pod --version
可能會(huì)錯(cuò)誤fatal: not in a git directory Error: Command failed with exit 128: git
設(shè)置 homebrew-cask 和 homebrew-core 的文件路徑為設(shè)置為safe.directory即可
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-services
M1芯片使用pod報(bào)錯(cuò) *** for architecture arm64
1泥技、添加如下配置 pod 和 工程都需要修改
2、Podfile最后添加如下代碼
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
end
end
3磕仅、重新安裝pod isntall
參考:
https://www.cnblogs.com/ZhangShengjie/p/15681901.html
https://blog.csdn.net/king14bhhb/article/details/126799622
https://blog.csdn.net/weixin_46926959/article/details/128135182