centos7安装nodejs指定版本

有时候,你发现通过以下的方式安装nodejs,由于系统环境等的问题,最后结果并不是你要的nodejs版本

  • 修改nodesource后,进行安装
  • 使用n 安装nodejs

修改nodesource后,进行安装

curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install –y nodejs
node –version

使用n 安装nodejs

sudo yum install –y nodejs
sudo npm install -g n
n 9.2.0
node –version

使用nvm安装nodejs指定版本

1. 下载nvm版本
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
2. 把nvm加入系统变量

使得在终端可以使用nvm命令

source   ~/.bashrc

nvm --version
3. 安装指定版本
nvm install 9.2.0

node -v
4. nvm其他常用命令
  nvm ls-remote  		查看远程版本列表
  nvm install 8.0.0                     Install a specific version number
  nvm use 8.0                           Use the latest available 8.0.x release
  nvm run 6.10.3 app.js                 Run app.js using node 6.10.3
  nvm exec 4.8.3 node app.js            Run `node app.js` with the PATH pointing to node 4.8.3
  nvm alias default 8.1.0               Set default node version on a shell
  nvm alias default node                Always default to the latest available node version on a shell
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值