安装 Node.js

切换到 root 用户

su

以 root 身份执行以下命令,添加 repo 仓库,这个 repo 里面有 nodejs 的 v16 版本

curl -fsSL https://rpm.nodesource.com/setup_16.x | bash -
yum repolist

源标识               源名称                                               状态
base/7/x86_64        CentOS-7 - Base                                      10,072
extras/7/x86_64      CentOS-7 - Extras                                       512
nodesource/x86_64    Node.js Packages for Enterprise Linux 7 - x86_64         76
updates/7/x86_64     CentOS-7 - Updates                                    3,842

退出 root 身份

exit

以 lishiqing 用户身份安装 nodejs 包

yum search nodejs
yum info nodejs
sudo yum -y install nodejs

查看 nodejs 版本

node -v

修改 npm 镜像

npm config set registry https://registry.npm.taobao.org

你可能感兴趣的:(安装 Node.js)