在 Rocky Linux 8 上,默认的 npm和Node版本太老,安装新版本的方法
添加指定版本的仓库(以 Node.js 18 为例,你可以把 18.x 换成 20.x 等):
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
之前安装的先删除
dnf remove nodejs npm -y
安装nodejs 和 npm
dnf install nodejs -y
添加指定版本的仓库(以 Node.js 18 为例,你可以把 18.x 换成 20.x 等):
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
之前安装的先删除
dnf remove nodejs npm -y
安装nodejs 和 npm
dnf install nodejs -y