nvm全称Node Version Manager是 Nodejs 版本管理器,它让我们能方便的对 Node.js 的版本进行切换。 nvm 的官方版本只支持 Linux 和 Mac。 Windows 用户,可以用 nvm-windows。详情请点击官方说明。
查资料得出,要使用 curl 或 wget 来安装nvm(版本可以选用官网最新版):
[linuxidc@localhost www.linuxidc.com]$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
输出示例如下:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 22484 0 --:--:-- --:--:-- --:--:-- 22545
=> Downloading nvm from git to '/home/linuxidc/.nvm'
=> 正克隆到 '/home/linuxidc/.nvm'...
remote: Enumerating objects: 286, done.
remote: Counting objects: 100% (286/286), done.
remote: Compressing objects: 100% (256/256), done.
remote: Total 286 (delta 34), reused 93 (delta 17), pack-reused 0
接收对象中: 100% (286/286), 146.90 KiB | 0 bytes/s, done.
处理 delta 中: 100% (34/34), done.
=> Compressing and cleaning up git repository
=> Appending nvm source string to /home/linuxidc/.bashrc
=> Appending bash_completion source string to /home/linuxidc/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
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_completion
或:
[linuxidc@localhost www.linuxidc.com]$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
注意:安装完了,重新打开终端 Terminal来重启会话
最新版
1、安装最新版 Node.js 命令:
[linuxidc@localhost www.linuxidc.com]$ nvm install node
Downloading and installing node v12.11.1...
Downloading https://nodejs.org/dist/v12.11.1/node-v12.11.1-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v12.11.1 (npm v6.11.3)
Creating default alias: default -> node (-> v12.11.1)
2.查看安装效果,命令:
[linuxidc@localhost www.linuxidc.com]$ nvm use node
新闻热点
疑难解答