banner
NEWS LETTER

使用nvm安装控制nodejs版本

Scroll down

安装nvm

两种方式

官网地址:https://github.com/nvm-sh/nvm#installing-and-updating

  • curl安装
1
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
  • wget安装
1
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

如果网络环境不太好的话容易报错

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

解决方法直接浏览器打开

https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh

然后把里面的代码复制到一个install.sh文件里面 在运行一下也是可以的

使用nvm安装/控制nodejs版本

  • 安装
1
2
nvm install 14
# 后面的14 就是代表所要安装的版本
  • 切换nodejs版本

注意:切换版本之前要先安装所要用到的版本

1
2
3
4
5
6
7
8
9
10
11
12
$ nvm use 16
Now using node v16.9.1 (npm v7.21.1)
$ node -v
v16.9.1
$ nvm use 14
Now using node v14.18.0 (npm v6.14.15)
$ node -v
v14.18.0
$ nvm install 12
Now using node v12.22.6 (npm v6.14.5)
$ node -v
v12.22.6
其他文章
请输入关键词进行搜索