美文网首页
CentOS 配置 Node 环境(使用NVM安装)

CentOS 配置 Node 环境(使用NVM安装)

作者: iCherries | 来源:发表于2019-12-22 17:21 被阅读0次

1、使用git将源码克隆到本地

yum install git
git clone https://github.com/cnpm/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`

2、激活NVM

echo ". ~/.nvm/nvm.sh" >> /etc/profile
source /etc/profile

3、查看 Node 所有版本

nvm list-remote

4、安装所需的 Node 版本

nvm install v12.14.0
nvm install v11.15.0

5、使用 nvm ls查看安装的 Node 版本

[root@xxx .nvm]# nvm ls
->     v11.15.0
       v12.14.0
stable -> 12.14 (-> v12.14.0) (default)
unstable -> 11.15 (-> v11.15.0) (default)

6、使用 nvm use v11.15.0 切换默认版本

提示:因为 cnpm 安装的模块路径,跟 npm 有所不同,有时不能用 cnpm 时, 可以切换淘宝源,切换后直接使用npm 即可

npx nrm use taobao    // 使用nrm 工具切换淘宝源
npx nrm use npm        // 切换回官方

相关文章

网友评论

      本文标题:CentOS 配置 Node 环境(使用NVM安装)

      本文链接:https://www.haomeiwen.com/subject/suionctx.html