linuxnodejs 20.* 安装问题,version `GLIBCXX_3.4.26‘

2024-01-03 12:58:29

背景

今天服务器被重置拉,nodejs 环境不存在,特意安装下nodejs,一访问官网,妈呀,居然到20版本拉!就尝试安装下最新版本!


过程

$ cd /opt
$ curl -OL https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.gz
$ tar -zxvf node-v20.10.0-linux-x64.tar.gz -C /usr/local/
$ cd /usr/local/
$ mv node-v20.10.0-linux-x64/ nodejs
$ ln -s /usr/local/nodejs/bin/node /usr/local/bin/node
$ ln -s /usr/local/nodejs/bin/npm /usr/local/bin/npm

到这里nodejs 安装基本完成拉


验证nodejs 出现问题

[root@localhost ~]# node -v
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
[root@localhost ~]# sudo find / -name "libstdc++.so.6*"
/usr/lib/libstdc++.so.6
/usr/lib/libstdc++.so.6.0.19
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.19-gdb.pyo


问题的原因

缺少libstdc++


网上解决方法

在这里插入图片描述


我自己的解决方法

查看自己电脑的库

[root@localhost ~]# strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_2.25
GLIBC_2.26
GLIBC_2.27
GLIBC_2.28
GLIBC_PRIVATE
___sys_errlist_GLIBC_2_3
___sys_errlist_GLIBC_2_4
___sys_errlist_GLIBC_2_1
___sys_nerr_GLIBC_2_1
___sys_nerr_GLIBC_2_3
___sys_nerr_GLIBC_2_4
___sys_nerr_GLIBC_2_3
___sys_nerr_GLIBC_2_4
___sys_nerr_GLIBC_2_1
__bdflush_GLIBC_2_0
[root@localhost ~]# sudo find / -name "libstdc++.so.6*"
/usr/lib/libstdc++.so.6
/usr/lib/libstdc++.so.6.0.19
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.19-gdb.pyo
[root@localhost ~]# sudo cp somewhere/libstdc++.so.6.0.25 /usr/lib64/
cp: cannot stat 'somewhere/libstdc++.so.6.0.25': No such file or directory
[root@localhost ~]# sudo cp somewhere /libstdc++.so.6.0.25 /usr/lib64/
cp: cannot stat 'somewhere': No such file or directory
cp: cannot stat '/libstdc++.so.6.0.25': No such file or directory

解决方式

[root@localhost ~]# cd /usr/local/lib64
[root@localhost lib64]# 
[root@localhost lib64]# 
[root@localhost lib64]# ls
[root@localhost lib64]# ll
total 0
[root@localhost lib64]# sudo wget http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zip
sudo: wget: command not found
[root@localhost lib64]# sudo curl -OL http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   162  100   162    0     0    467      0 --:--:-- --:--:-- --:--:--   466
100 4068k  100 4068k    0     0   267k      0  0:00:15  0:00:15 --:--:--  263k
[root@localhost lib64]# ls
libstdc.so_.6.0.26.zip
[root@localhost lib64]# pwd
/usr/local/lib64
[root@localhost lib64]# sudo unzip libstdc.so_.6.0.26.zip
sudo: unzip: command not found
[root@localhost lib64]# sudo yum install unzip -y
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * centos-sclo-rh: mirrors.ustc.edu.cn
 * centos-sclo-sclo: mirrors.ustc.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package unzip.x86_64 0:6.0-24.el7_9 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                Arch                    Version                        Repository                Size
==============================================================================================================
Installing:
 unzip                  x86_64                  6.0-24.el7_9                   updates                  172 k

Transaction Summary
==============================================================================================================
Install  1 Package

Total download size: 172 k
Installed size: 369 k
Downloading packages:
unzip-6.0-24.el7_9.x86_64.rpm                                                          | 172 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : unzip-6.0-24.el7_9.x86_64                                                                  1/1 
  Verifying  : unzip-6.0-24.el7_9.x86_64                                                                  1/1 

Installed:
  unzip.x86_64 0:6.0-24.el7_9                                                                                 

Complete!

[root@localhost lib64]# sudo unzip libstdc.so_.6.0.26.zip
Archive:  libstdc.so_.6.0.26.zip
  inflating: libstdc++.so.6.0.26     
[root@localhost lib64]# 
[root@localhost lib64]# 
[root@localhost lib64]# ll
total 16940
-rwxrwxr-x. 1 root root 13172960 Jun 10  2019 libstdc++.so.6.0.26
-rw-r--r--. 1 root root  4165669 Jan  4 02:13 libstdc.so_.6.0.26.zip

[root@localhost lib64]# sudo cp libstdc++.so.6.0.26 /usr/lib64
[root@localhost lib64]# cd /usr/lib64
[root@localhost lib64]# ls -l | grep libstdc++ (just to check the symlink)
-bash: syntax error near unexpected token `('
[root@localhost lib64]# ls -l | grep libstdc++
lrwxrwxrwx.  1 root root       19 Dec 27 02:58 libstdc++.so.6 -> libstdc++.so.6.0.19
-rwxr-xr-x.  1 root root   995840 Sep 30  2020 libstdc++.so.6.0.19
-rwxr-xr-x.  1 root root 13172960 Jan  4 02:14 libstdc++.so.6.0.26
[root@localhost lib64]# sudo rm libstdc++.so.6
[root@localhost lib64]# sudo ln -s libstdc++.so.6.0.26 libstdc++.so.6
[root@localhost lib64]# ls -l | grep libstdc++
lrwxrwxrwx.  1 root root       19 Jan  4 02:15 libstdc++.so.6 -> libstdc++.so.6.0.26
-rwxr-xr-x.  1 root root   995840 Sep 30  2020 libstdc++.so.6.0.19
-rwxr-xr-x.  1 root root 13172960 Jan  4 02:14 libstdc++.so.6.0.26
[root@localhost lib64]# node -v
v20.10.0
[root@localhost lib64]# 
[root@localhost lib64]# 
[root@localhost lib64]# 

Tips

因为没有安装 wget 所以使用的curl,因为下载的是zip 所以安装unzip 解压工具

更多issues

文章来源:https://blog.csdn.net/alnorthword/article/details/135356766
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。