Mac安裝nvm


安裝nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh | bash

可能會出現以下錯誤

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

解決方案

終端輸入

sudo vim /etc/hosts

添加以下內容

199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com

檢查是否安裝成功

終端輸入

nvm --version

可能會出現以下錯誤

zsh: command not found: nvm

解決方案

open ~/.bash_profile 

在文件中加入以下內容

export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh

重啟bash_profile

source .bash_profile

再次輸入 nvm -v 安裝成功

還可能出現的問題

環境變量添加后,每次打開終端都需要重新 source .bash_profile 才能使nvm生效,否則依然提示 zsh: command not found: nvm

解決方案

把bash_profile添加到.zshrc中

在終端輸入

vim .zshrc

插入以下內容

source ~/.bash_profile

重啟.zshrc

source .zshrc

vim操作命令

i 在當前行插入內容
:wq 保存退出

注意

需確保 Mac 中安裝了 git,一般只要你下載了 Mac 的 Xcode 開發工具,它是自帶 git 的。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM