CentOS 7 安装 Node.js

使用 Node 版本管理工具进行安装

有很多工具可供选择,但这次决定使用nodenv。
为了安装nodenv,还需要同时安装node-build。

下載目標物件
git clone https://github.com/nodenv/nodenv.git ~/.nodenv
git clone https://github.com/nodenv/node-build.git ~/.nodenv/plugins/node-build

把路径设为通行,
把 ‘export PATH=”$HOME/.nodenv/bin:$PATH”‘ 写入 ~/.bash_profile,
把 ‘eval “$(nodenv init -)”‘ 写入 ~/.bash_profile,
加载 ~/.bash_profile。

确认一下当前已完成的节点版本安装。使用”nodenv -v”命令。

当写这篇文章时,V10是最新版本,需要将版本更新为v10。使用nodenv install 10.10.0命令进行安装,然后使用nodenv global 10.10.0命令进行全局设置。

确认已安装
node -v

bannerAds