# 版本号支持:lts.x current.x 5.x 6.x 7.x 8.x 10.x 12.x 14.x 16.x
# CentOS
curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash - # As root
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - # No root privileges
yum install -y nodejs # 安装
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
# help
https://github.com/nodesource/distributions
# 显示版本
node -v
# 方式2:下载解压
https://nodejs.org/en/download/
http://nodejs.cn/download/
# 下载、解压
wget https://oss.npmmirror.com/dist/node/v17.1.0/node-v17.1.0-linux-x64.tar.xz
tar -xvf node-v17.1.0-linux-x64.tar.xz
# 修改文件夹
mv node-v17.1.0-linux-x64 nodejs
# nodejs下bin目录是否有node 和npm
# 建立软连接,变为全局
echo $PATH # 查看已配置路径
ln -s /netnr/run/nodejs/bin/npm /usr/local/bin/
ln -s /netnr/run/nodejs/bin/node /usr/local/bin/