赞
踩
删除 pkg 安转的 node
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
删除brew 安装的 node
brew uninstall node
node卸载完成后
brew install nvm
安装完成后会显示一段内容
You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm
Add the following to ~/.config/fish/config.fish or your desired shell
configuration file:
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.
根据上述信息得知应在 配置文件中加入以上内容
打开 zsh Config 将 以下内容复制到.zshrc中
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
export NVM_NODEJS_ORG_MIRROR = https://npm.taobao.org/mirrors/node # 由于节点在国外在这里换镜像源
vim ~/.zshrc
保存后新开终端或者在原终端窗口重新加载配置文件即可
source ~/.zshrc
安装 bass (如果安装失败或者掉包请在终端中配置代理)
omf install bass
打开 config.fish
vim ~/.config/fish/config.fish
将以下代码复制到 config.fish (代码中source 的路径请以mac中实际的路径为准)
function nvm
bass source /Users/apple/.nvm/nvm.sh ';' nvm $argv
end
最后还是依然沿用之前的操作(新开终端或者在原终端窗口重新加载配置文件即可)
source ~/.config/fish/config.fish
最后
上述有错误或者不完善的地方欢迎大家指出,关注我,不迷路~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。