centos7 yum -y install nodejs安装npm时报错,处理方法

发布时间 2023-03-26 17:28:36作者: zhg1016

 

centos7 yum -y install nodejs安装npm时报错,处理方法

安装npm时报错,处理方法

sudo: npm: command not found

sudo yum -y install nodejs
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: ftp.sjtu.edu.cn
No package nodejs available.
Error: Nothing to do

 

使用 centos7用 4.x    centos8用5.x 

# 4.x
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
# 5.x
curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
仍然报错

+ rpm -i --nosignature --force '/tmp/tmp.VzZOZxEXib'
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
Error executing command, exiting

 

 切换ROOT用户安装

重新执行 

# 4.x
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -

完成安装,没有报错

 

然后执行 yum install -y nodejs 

以上是因为yum资源没有nodejs的包,要自己找资源包安装,解决。centos已被遗弃。尽快完成ubuntu的切换工作。