【debug】centos7
場景
centos7服務器使用nvm安裝的node之後,只要使用npm或者node,均會出現以下問題
xxxxxxxxxx1
[root@172 ~]# npm -v2
node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)3
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)4
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)5
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)6
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)7
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)8
原因
查看系統內安裝的glibc版本
然後再根據分析可得知新版的node v18開始都需要GLIBC_2.27支持,可是目前系統內卻沒有那麼高的版本
xxxxxxxxxx1
[root@172 glibc-2.28]# strings /lib64/libc.so.6 |grep GLIBC_2
GLIBC_2.2.53
...4
GLIBC_2.175
....6
解決辦法
更新glibc
根據提示安裝所需要的glibc-2.28
xxxxxxxxxx1
wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz2
tar xf glibc-2.28.tar.gz 3
cd glibc-2.28/ && mkdir build && cd build4
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin5
可能出現的錯誤
上步更新glibc 可能會發生錯誤。
如果沒有錯誤下邊這一步不用看。
make問題
xxxxxxxxxx1
configure: error: 2
*** These critical programs are missing or too old: make bison compiler3
*** Check the INSTALL file for required versions.4
解決辦法:升級gcc與make
xxxxxxxxxx1
# 升级GCC(默认为4 升级为8)2
yum install -y centos-release-scl3
yum install -y devtoolset-8-gcc*4
mv /usr/bin/gcc /usr/bin/gcc-4.8.55
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc6
mv /usr/bin/g++ /usr/bin/g++-4.8.57
ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++8
9
# 升级 make(默认为3 升级为4)10
wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz11
tar -xzvf make-4.3.tar.gz && cd make-4.3/12
./configure --prefix=/usr/local/make13
make && make install14
cd /usr/bin/ && mv make make.bak15
ln -sv /usr/local/make/bin/make /usr/bin/make16
這時所有的問題都已經解決完畢再重新執行上一步更新glibc即可
xxxxxxxxxx1
cd /root/glibc-2.28/build2
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin3
我的依舊報錯:bison太老舊
xxxxxxxxxx1
configure: error: 2
*** These critical programs are missing or too old: bison3
*** Check the INSTALL file for required versions.4
看看我的bison版本多少
xxxxxxxxxx1
[root@172 ~]# bison -v2
-bash: bison: 未找到命令3
bison問題
嗨,沒裝啊。裝一下唄
xxxxxxxxxx1
yum install -y bison2
這時所有的問題真的真的都已經解決完畢再重新執行上一步更新glibc即可
xxxxxxxxxx1
cd /root/glibc-2.28/build2
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin3
繼續更新glibc
make 和make install在linux中就是安裝軟件的意思簡單這麼理解就好。
這個過程較長,大約半小時左右,建議打一局遊戲就好了。
xxxxxxxxxx1
make && make install2
``3
4
验证下 是不是好了5
```shell6
npm -v7