赞
踩
centos 下使用 yum 默认安装的 nodejs 版本为 v6.x。可以使用 n 命令来升级切换 nodejs 版本。
1.安装 n 命令
$ npm install -g n
2.使用 n 安装 nodejs 版本
安装最新版本
$ n latest
安装指定版本
$ n node/13.11.0
切换 nodejs 版本
$ n
选择已安装的版本
node/10.4.1
ο node/13.11.0
Use up/down arrow keys to select a version, return key to install, d to delete, q to quit
使用 node -v 命令,查看当前版本,如果显示如下则表示切换成功。
v13.11.0
注意:切换之后,查看版本如果还是原来 v6.x 版本,需要设置一下 PATH
$ which node
/usr/local/bin/node
$ vi ~/.bash_profile
将下边两行插入到文件末尾:
export N_PREFIX=/usr/local
export PATH=$N_PREFIX/bin:$PATH
:wq 保存退出
执行 source 使修改立即生效
$ source ~/.bash_profile
再执行 node -v 命令查看版本是否切换成功。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。