Linux环境yum安装nodejs

275 阅读1分钟

centos8 修改yum源

1.备份repo文件

cd /etc/yum.repos.d/
mkdir repBak
mv *.repo repBak/

2.下载repo文件

repo 镜像站 mirrors.aliyun.com/repo/

ubuntu源 github.com/nodesource/…

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

3.生成yum缓存

yum makecache

4.查找nodejs的yum源并进行设置

github.com/nodesource/…

# 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 -

5.通过yum安装nodejs

yum -y install nodejs

6.检查是否安装成功

node -v
npm -v