1、从官网下载Node.js
https://nodejs.org/en/download/
版本分为: LTS 和 Current
LTS: Long Term Support 版:即长期支持版,相对于其他版本来说更加稳定,建议生产环境下使用
Current : 最新版,支持最新特性
2、 下载 Linux Binaries (X64)
下载后的包名为: node-v12.18.3-linux-x64.tar.xz
注意: tar.xz 这是两层压缩,外面是xz压缩,里层是tar压缩,所以分两步实现解压
xz -d node-v12.18.3-linux-x64.tar.xz tar xvf node-v12.18.3-linux-x64.tar
3、 配置node.js
由于下载的直接是二进制可执行文件
#从解压目录存放,拷贝到/usr/local下
mv node-v12.18.3-linux-x64 /usr/local/
#配置软连接
ln -s -f /usr/local/node-v12.18.3-linux-x64/bin/node /usr/local/bin/node
ln -s -f /usr/local/node-v12.18.3-linux-x64/bin/npm /usr/local/bin/npm
#查看版本
npm -v
完成安装