以下操作基于root用户
curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash -
sudo yum install -y nodejs
安装完成后通过命令验证版本
其他长期版本安装参考:
Node.js v18.x
# As root curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - # No root privileges curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
Node.js v16.x
# As root curl -fsSL https://rpm.nodesource.com/setup_16.x | bash - # No root privileges curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
Node.js v14.x
# As root curl -fsSL https://rpm.nodesource.com/setup_14.x | bash - # No root privileges curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -
Node.js LTS (16.x)
# As root curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash - # No root privileges curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
Node.js Current (18.x)
# As root curl -fsSL https://rpm.nodesource.com/setup_current.x | bash - # No root privileges curl -fsSL https://rpm.nodesource.com/setup_current.x | sudo bash -
# use `sudo` or run this as root yum remove nodejs rm -r /etc/yum.repos.d/nodesource*.repo yum clean all
更多参考:distributions/README.md at master · nodesource/distributions · GitHub
https://www.leftso.com/article/1075.html