背景
今天服务器被重置拉,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 -vnode: /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.5GLIBC_2.2.6GLIBC_2.3GLIBC_2.3.2GLIBC_2.3.3GLIBC_2.3.4GLIBC_2.4GLIBC_2.5GLIBC_2.6GLIBC_2.7GLIBC_2.8GLIBC_2.9GLIBC_2.10GLIBC_2.11GLIBC_2.12GLIBC_2.13GLIBC_2.14GLIBC_2.15GLIBC_2.16GLIBC_2.17GLIBC_2.18GLIBC_2.22GLIBC_2.23GLIBC_2.24GLIBC_2.25GLIBC_2.26GLIBC_2.27GLIBC_2.28GLIBC_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 directorycp: 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]# lltotal 0
[root@localhost lib64]# sudo wget http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zipsudo: 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 % XferdAverage Speed TimeTime TimeCurrent DloadUpload Total SpentLeftSpeed100 162100 1620 04670 --:--:-- --:--:-- --:--:-- 466100 4068k100 4068k0 0 267k00:00:150:00:15 --:--:--263k[root@localhost lib64]# lslibstdc.so_.6.0.26.zip[root@localhost lib64]# pwd/usr/local/lib64[root@localhost lib64]# sudo unzip libstdc.so_.6.0.26.zipsudo: unzip: command not found[root@localhost lib64]# sudo yum install unzip -yFailed to set locale, defaulting to CLoaded plugins: fastestmirrorLoading 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.cnResolving Dependencies--> Running transaction check---> Package unzip.x86_64 0:6.0-24.el7_9 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================== PackageArchVersionRepositorySize==============================================================================================================Installing: unzipx86_646.0-24.el7_9 updates172 kTransaction Summary==============================================================================================================Install1 PackageTotal download size: 172 kInstalled size: 369 kDownloading packages:unzip-6.0-24.el7_9.x86_64.rpm| 172 kB00:00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling : unzip-6.0-24.el7_9.x86_641/1 Verifying: unzip-6.0-24.el7_9.x86_641/1 Installed:unzip.x86_64 0:6.0-24.el7_9 Complete!
[root@localhost lib64]# sudo unzip libstdc.so_.6.0.26.zipArchive:libstdc.so_.6.0.26.zipinflating: libstdc++.so.6.0.26 [root@localhost lib64]# [root@localhost lib64]# [root@localhost lib64]# lltotal 16940-rwxrwxr-x. 1 root root 13172960 Jun 102019 libstdc++.so.6.0.26-rw-r--r--. 1 root root4165669 Jan4 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 302020 libstdc++.so.6.0.19-rwxr-xr-x.1 root root 13172960 Jan4 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 Jan4 02:15 libstdc++.so.6 -> libstdc++.so.6.0.26-rwxr-xr-x.1 root root 995840 Sep 302020 libstdc++.so.6.0.19-rwxr-xr-x.1 root root 13172960 Jan4 02:14 libstdc++.so.6.0.26
[root@localhost lib64]# node -vv20.10.0[root@localhost lib64]# [root@localhost lib64]# [root@localhost lib64]#
Tips
因为没有安装 wget
所以使用的curl
,因为下载的是zip 所以安装unzip 解压工具
更多issues