Nvm安装成功后,使用nvm命令却提示command not found,mac终端解决办法如下: 1、进入nvm安装到文件目录
cd ~/.nvm
2、查看目录下文件列表
ls
3、若无.bash_profile文件,则创建该文件:
创建文件步骤:
3.1 touch .bash_profile
3.2 open .bash_profile
3.3 将下部分文件粘贴至 .bash_profile文件 最简单curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
或者手动将export NVM_DIR="/Users/magicdawn/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
加到 ~/.bash_profile , zsh的话是 ~/.zshrc
(此语句是配置文件,与自己电脑有关,若不知道,可运行如下命令,会提示这段语句)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
3.4 保存文件,关闭此文件
3.5 更新刚配置的环境变亮
source .bash_profile
4、输入nvm命令,验证是否成功,
例如nvm use 6.10.2,若已安装node 该版本node,则提示已切换至此版本, 若无安装,则提示未安装此版本,请安装。 此时,nvm可正常使用