RHEL8 CentOS7 安装 nodejs
首先确保机器上安装了 epel(多了一个源选项)
Rocky Linux 9 / RHEL 8
列出源
Bash
dnf module list nodejsPlaintext
Last metadata expiration check: 0:00:34 ago on Tue 29 Aug 2023 12:12:02 PM CST.
Rocky Linux 9 - AppStream
Name Stream Profiles Summary
nodejs 18 [e] common [d], development, minimal, s2i Javascript runtime
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled启用源
Bash
dnf module enable nodejs:18安装
Bash
dnf module install nodejsCentOS 7 安装
Bash
yum install nodejs
yum install npm创建文件夹并给文件夹赋予权限
Plaintext
$ sudo mkdir -p /usr/local/lib/node_modules/
$ sudo chown -R root:$(whoami) /usr/local/lib/node_modules/
$ chmod -R 775 /usr/local/lib/node_modules/安装全局的命令需要使用 sudo 提权
Plaintext
$ sudo npm install -g apidoc配置 node 环境
安装 nrm, 方便切换镜像源
Plaintext
# npm install -g nrm --registry=https://registry.npmmirror.com切换镜像源
Plaintext
$ nrm use taobao