yum install nodejs -- No package nodejs available.

背景和问题


linux 上没有nodejs 环境需要安装一下

执行了:

yum install nodejs

报错:

No package nodejs available.

没有可用的安装包。

 

分析和纠错过程


网上百度了下首先需要获取nodejs资源,然后再安装:

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

然后安装yum install -y nodejs ,确实可以安装完之后发现了是node4 版本,

现在都17.x 了。

想着再获取新的资源试试:

# 16.x

curl --silent --location https://rpm.nodesource.com/setup_16.x | bash -

然后安装,还是4.x 版本,怎么删去以前的呢?

解决

删除旧的nodejs资源:

sudo rm -fv /etc/yum.repos.d/nodesource*

然后获取对应Nodejs 版本资源,最后安装。

[root@VM-16-7-centos UnblockNeteaseMusic]# curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash - # 选v20 LTS版 2025-05-14 13:45:45 - Cleaning up old repositories... 2025-05-14 13:45:45 - Old repositories removed 2025-05-14 13:45:45 - Supported architecture: x86_64 2025-05-14 13:45:45 - Added N|Solid repository for LTS version: 20.x 2025-05-14 13:45:45 - yum available, updating... 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile nodesource-nodejs | 3.0 kB 00:00:00 (1/3): nodesource-nodejs/primary_db | 57 kB 00:00:01 (2/3): nodesource-nodejs/filelists_db | 615 kB 00:00:02 (3/3): nodesource-nodejs/other_db | 7.7 kB 00:00:00 元数据缓存已建立 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile nodesource-nsolid | 3.0 kB 00:00:00 (1/3): nodesource-nsolid/primary_db | 28 kB 00:00:00 (2/3): nodesource-nsolid/other_db | 2.7 kB 00:00:00 (3/3): nodesource-nsolid/filelists_db | 514 kB 00:00:02 元数据缓存已建立 2025-05-14 13:45:53 - Repository is configured and updated. 2025-05-14 13:45:53 - You can use N|solid Runtime as a node.js alternative 2025-05-14 13:45:53 - Run 'yum install nsolid -y' to complete the installation. 2025-05-14 13:45:53 - Run 'yum install nodejs -y' to complete the installation. [root@VM-16-7-centos UnblockNeteaseMusic]# sudo yum clean all && sudo yum install -y nodejs 已加载插件:fastestmirror, langpacks 正在清理软件源: epel extras nodesource-nodejs nodesource-nsolid os updates Cleaning up list of fastest mirrors 已加载插件:fastestmirror, langpacks Determining fastest mirrors epel | 4.3 kB 00:00:00 extras | 2.9 kB 00:00:00 nodesource-nodejs | 3.0 kB 00:00:00 nodesource-nsolid | 3.0 kB 00:00:00 os | 3.6 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/9): epel/7/x86_64/group | 399 kB 00:00:00 (2/9): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00 (3/9): epel/7/x86_64/primary_db | 8.7 MB 00:00:00 (4/9): os/x86_64/group_gz | 153 kB 00:00:00 (5/9): extras/x86_64/primary_db | 253 kB 00:00:00 (6/9): nodesource-nodejs/primary_db | 57 kB 00:00:00 (7/9): updates/x86_64/primary_db | 27 MB 00:00:00 (8/9): os/x86_64/primary_db | 6.1 MB 00:00:01 (9/9): nodesource-nsolid/primary_db | 28 kB 00:00:01 正在解决依赖关系 There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help). --> 正在检查事务 ---> 软件包 nodejs.x86_64.1.16.20.2-1.el7 将被 升级 ---> 软件包 nodejs.x86_64.2.20.19.1-1nodesource 将被 更新 --> 正在处理依赖关系 glibc >= 2.28,它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libm.so.6(GLIBC_2.27)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libstdc++.so.6(CXXABI_1.3.9)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libstdc++.so.6(GLIBCXX_3.4.20)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libstdc++.so.6(GLIBCXX_3.4.21)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libc.so.6(GLIBC_2.28)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 解决依赖关系完成 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libstdc++.so.6(GLIBCXX_3.4.20)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:glibc >= 2.28 已安装: glibc-2.17-326.el7_9.3.x86_64 (@updates) glibc = 2.17-326.el7_9.3 可用: glibc-2.17-317.el7.i686 (os) glibc = 2.17-317.el7 可用: glibc-2.17-322.el7_9.i686 (updates) glibc = 2.17-322.el7_9 可用: glibc-2.17-323.el7_9.i686 (updates) glibc = 2.17-323.el7_9 可用: glibc-2.17-324.el7_9.i686 (updates) glibc = 2.17-324.el7_9 可用: glibc-2.17-325.el7_9.i686 (updates) glibc = 2.17-325.el7_9 可用: glibc-2.17-326.el7_9.i686 (updates) glibc = 2.17-326.el7_9 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libm.so.6(GLIBC_2.27)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libstdc++.so.6(CXXABI_1.3.9)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libc.so.6(GLIBC_2.28)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libstdc++.so.6(GLIBCXX_3.4.21)(64bit) 您可以尝试添加 --skip-broken 选项来解决该问题 ** 发现 1 个已存在的 RPM 数据库问题, 'yum check' 输出如下: mpi-selector-1.0.3-1.54310.x86_64 是 mpi-selector-1.0.3-1.51258.x86_64 的副本 [root@VM-16-7-centos UnblockNeteaseMusic]# node -v # 验证版本应≥v20.12.2 v16.20.2 [root@VM-16-7-centos UnblockNeteaseMusic]# # CentOS证书默认路径 [root@VM-16-7-centos UnblockNeteaseMusic]# export NODE_EXTRA_CA_CERTS=/etc/pki/tls/certs/ca-bundle.crt [root@VM-16-7-centos UnblockNeteaseMusic]# # 永久生效则写入~/.bashrc [root@VM-16-7-centos UnblockNeteaseMusic]# echo 'export NODE_EXTRA_CA_CERTS=/etc/pki/tls/certs/ca-bundle.crt' >> ~/.bashrc [root@VM-16-7-centos UnblockNeteaseMusic]# npm install --verbose fuse.js # 观察下载源是否为npmmirror.com -bash: npm: 未找到命令 [root@VM-16-7-centos UnblockNeteaseMusic]# curl -I https://registry.npmmirror.com # 检查返回200状态码
05-15
[root@localhost ~]# cd Downloads/ [root@localhost Downloads]# yum install java-1.8.0-openjdk-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: ftp-stud.hs-esslingen.de * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.412.b08-1.el7_9 will be installed --> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.412.b08-1.el7_9 for package: 1:java-1.8.0-openjdk-devel-1.8.0.412.b08-1.el7_9.x86_64 --> Running transaction check ---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.332.b09-1.el7_9 will be updated ---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.412.b08-1.el7_9 will be an update --> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.412.b08-1.el7_9 for package: 1:java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64 --> Running transaction check ---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.332.b09-1.el7_9 will be updated ---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.412.b08-1.el7_9 will be an update --> Processing Dependency: tzdata-java >= 2023d for package: 1:java-1.8.0-openjdk-headless-1.8.0.412.b08-1.el7_9.x86_64 --> Running transaction check ---> Package tzdata-java.noarch 0:2022a-1.el7 will be updated ---> Package tzdata-java.noarch 0:2024a-1.el7 will be an update --> Finished Dependency Resolution /var/cache/yum/x86_64/7/base/gen/comps.xml: no element found: line 1, column 0 Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: java-1.8.0-openjdk-devel x86_64 1:1.8.0.412.b08-1.el7_9 updates 9.9 M Updating for dependencies: java-1.8.0-openjdk x86_64 1:1.8.0.412.b08-1.el7_9 updates 325 k java-1.8.0-openjdk-headless x86_64 1:1.8.0.412.b08-1.el7_9 updates 33 M tzdata-java noarch 2024a-1.el7 updates 187 k Transaction Summary ================================================================================ Install 1 Package Upgrade ( 3 Dependent packages) Total download size: 44 M Is this ok [y/d/N]: y Downloading packages: No Presto metadata available for updates (1/4): java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64.rpm | 325 kB 00:00 (2/4): java-1.8.0-openjdk-devel-1.8.0.412.b08-1.el7_9.x86_ | 9.9 MB 00:21 (3/4): tzdata-java-2024a-1.el7.noarch.rpm | 187 kB 00:00 (4/4): java-1.8.0-openjdk-headless-1.8.0.412.b08-1.el7_9.x | 33 MB 01:12 -------------------------------------------------------------------------------- Total 608 kB/s | 44 MB 01:13 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : tzdata-java-2024a-1.el7.noarch 1/7 Updating : 1:java-1.8.0-openjdk-headless-1.8.0.412.b08-1.el7_9.x86_64 2/7 warning: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.policy created as /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.policy.rpmnew warning: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.security created as /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.security.rpmnew restored /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.policy.rpmnew to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.policy restored /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.security.rpmnew to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/security/java.security Updating : 1:java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64 3/7 Installing : 1:java-1.8.0-openjdk-devel-1.8.0.412.b08-1.el7_9.x86_64 4/7 Cleanup : 1:java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64 5/7 Cleanup : 1:java-1.8.0-openjdk-headless-1.8.0.332.b09-1.el7_9.x86_64 6/7 Cleanup : tzdata-java-2022a-1.el7.noarch 7/7 Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.412.b08-1.el7_9.x86_64 1/7 Verifying : tzdata-java-2024a-1.el7.noarch 2/7 Verifying : 1:java-1.8.0-openjdk-devel-1.8.0.412.b08-1.el7_9.x86_64 3/7 Verifying : 1:java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64 4/7 Verifying : tzdata-java-2022a-1.el7.noarch 5/7 Verifying : 1:java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64 6/7 Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.332.b09-1.el7_9.x86_64 7/7 Installed: java-1.8.0-openjdk-devel.x86_64 1:1.8.0.412.b08-1.el7_9 Dependency Updated: java-1.8.0-openjdk.x86_64 1:1.8.0.412.b08-1.el7_9 java-1.8.0-openjdk-headless.x86_64 1:1.8.0.412.b08-1.el7_9 tzdata-java.noarch 0:2024a-1.el7 Complete! [root@localhost Downloads]# history 1 yum -y install gcc gcc-c++ openssl-devel 2 cd Downloads/ 3 wget https://nodejs.org/dist/v6.9.2/node-v6.9.2.tar.gz 4 ls 5 cd .. 6 ls 7 mkdir node 8 cd node 9 tar -xzf ~/Downloads/node-v6.9.2.tar.gz -C ./ 10 ls -l 11 cd .. 12 cd Downloads/ 13 cd node-v6.9.2.tar.gz 14 ls 15 cd node-v6.9.2.tar.gzcd .. 16 cd .. 17 cd node 18 ls 19 cd node-v6.9.2/ 20 ./configure 21 make -j$(nproc) 22 history 23 make install 24 node -v 25 npm -v 26 node --version 27 gcc --version 28 cd .. 29 mkdir -p /data/redis 30 cd /data/redis 31 wget https://download.redis.io/releases/redis-7.0.2.tar.gz 32 ls 33 tar -zxvf redis-7.0.2.tar.gz 34 ls -l 35 cd redis-7.0.2 36 make 37 sudo mkdir -p /etc/redis 38 sudo mkdir -p /var/lib/redis 39 ls -l 40 sudo cp redis.conf /etc/redis/ 41 cd .. 42 l -l 43 ls -l 44 cd .. 45 ls -l 46 cd .. 47 ls -l 48 cd etc/ 49 ls -l 50 cd redis 51 ls -l 52 vi redis.conf 53 redis-server /etc/redis/redis.conf 54 redis-server /redis.conf 55 cd .. 56 cd data 57 cd redis 58 sudo cp /data/redis/redis-7.0.2/src/redis-server /usr/bin/ 59 sudo cp /data/redis/redis-7.0.2/src/redis-cli /usr/bin/ 60 sudo cp /data/redis/redis-7.0.2/src/redis-benchmark /usr/bin/ 61 sudo cp /data/redis/redis-7.0.2/src/redis-check-aof /usr/bin/ 62 sudo cp /data/redis/redis-7.0.2/src/redis-check-rdb /usr/bin/ 63 sudo cp /data/redis/redis-7.0.2/src/redis-sentinel /usr/bin/ 64 cd /user/bin 65 cd .. 66 cd user 67 pwd 68 cd root 69 cd bin 70 ls 71 cd .. 72 ls 73 cd bin 74 ls -l 75 redis-server /etc/redis/redis.conf 76 cd .. 77 cd etc 78 ls -l 79 vi sysctl.conf 80 sysctl -p 81 cd .. 82 redis-server /etc/redis/redis.conf 83* redis-cil ping./ 84 cd bin 85* 86 ls l 87 ls -l 88 redis-server /etc/redis/redis.conf 89 cd .. 90 ls -l 91 cd root 92 cd Downloads/ 93 yum install java-1.8.0-openjdk-devel 94 history [root@localhost Downloads]# ls -l total 25904 -rw-r--r--. 1 root root 26522709 Dec 7 2016 node-v6.9.2.tar.gz [root@localhost Downloads]#
最新发布
10-24
在安装 `zabbix-web-mysql-scl` 时,若提示缺少 `rh-php72` 相关依赖,且尝试安装 `rh-php72-php-mbstring` 等模块失败,提示 `No package available`,这通常表明系统中的 SCL(Software Collections)源配置存在问题,或者默认的镜像源无法正常访问。 在 `/etc/yum.repos.d/` 目录下,应确保存在 `CentOS-SCLo-scl.repo` 和 `CentOS-SCLo-scl-rh.repo` 文件。如果这些文件缺失或内容不完整,应重新安装 `centos-release-scl` 包,并替换默认镜像源为国内镜像以提高可用性。例如,可以使用阿里云镜像源进行替换: ```bash rpm -qa | grep centos-release-scl rpm -e $(rpm -qa | grep centos-release-scl) yum -y install centos-release-scl ``` 替换镜像源配置: ```bash sed -i 's/^mirrorlist/#&/;s/^# baseurl/baseurl/;s|http://mirror.centos.org|https://mirrors.aliyun.com|' /etc/yum.repos.d/CentOS-SCLo-scl.repo sed -i 's/^mirrorlist/#&/;s/^#baseurl/baseurl/;s|http://mirror.centos.org|https://mirrors.aliyun.com|' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo ``` 完成源配置后,清理并重建缓存: ```bash yum clean all yum makecache yum repolist ``` 此时,应能正常安装所需的 PHP 模块: ```bash yum install rh-php72-php-mbstring rh-php72-php-bcmath rh-php72-php-gd rh-php72-php-mysqlnd rh-php72-php-xml rh-php72-php-ldap rh-php72-php-fpm rh-php72 -y ``` 最后,安装 Zabbix Web 组件: ```bash yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y ``` 通过上述步骤,可以有效解决因源配置问题导致的依赖缺失问题,从而成功安装 Zabbix Web 组件 [^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星宇大前端

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值