1.安装nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
2 载入nvm环境
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
3使用nvm
安装指定版本的Node.js
nvm install 20
4使用nvm
切换到新版本的Node.js
nvm use 20
5确认Node.js版本
node --version
错误提示:
node --version node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node) node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node) node: /lib64/libc.so.6: version `GLIBC_2.28' 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.20' not found (required by node) node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
解决办法:更新glibc
wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz tar xf glibc-2.28.tar.gz cd glibc-2.28/ && mkdir build && cd build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
更新glibc 发生错误
configure: error: *** These critical programs are missing or too old: make bison compiler *** Check the INSTALL file for required versions.
解决办法:升级gcc与make
# 升级GCC(默认为4 升级为8)</span> yum install -y centos-release-scl yum install -y devtoolset-8-gcc* mv /usr/bin/gcc /usr/bin/gcc-4.8.5 ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc mv /usr/bin/g++ /usr/bin/g++-4.8.5 ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++ # 升级 make(默认为3 升级为4) wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz tar -xzvf make-4.3.tar.gz && cd make-4.3/ ./configure --prefix=/usr/local/make make && make install cd /usr/bin/ && mv make make.bak ln -sv /usr/local/make/bin/make /usr/bin/make
yum install -y devtoolset-8-gcc*
执行后报错Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64
解决方法:
重命名原来的文件:
cd /etc/yum.repos.d/ mv CentOS-SCLo-scl.repo CentOS-SCLo-scl.repo.bak mv CentOS-SCLo-scl-rh.repo CentOS-SCLo-scl-rh.repo.bak
编辑文件
vim CentOS-SCLo-rh.repo
粘贴并保存一下内容
[centos-sclo-rh] name=CentOS-7 - SCLo rh baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
gcc和make全部升级完成后,再次更新glibc
cd /root/glibc-2.28/build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
依旧报错,bison版本太老
configure: error: *** These critical programs are missing or too old: bison *** Check the INSTALL file for required versions.
查看bison版本
bison -v -bash: bison: 未找到命令
未安装执行安装命令
yum install -y bison
安装成功后,再次更新glibc
cd /root/glibc-2.28/build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
安装glibc
make && make install
遇到新问题
primary library! make[1]: *** [Makefile:111: install] Error 1 make[1]: Leaving directory '/root/glibc-2.28' make: *** [Makefile:12: install] Error 2
查看现在的node版本
node -v
报错如下:
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node) node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node) node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
解决方法
yum install libstdc++.so.6 -y
查看动态链接库 -- 发现并没有需要的1.3.9
strings /usr/lib/libstdc++.so.6 | grep 'CXXABI'
下载需要的版本库,之后软连接到运行系统上
wget http://ftp.de.debian.org/debian/pool/main/g/gcc-8/libstdc++6_8.3.0-6_amd64.deb wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/389-ds-base-1.3.10.2-6.el7.x86_64.rpm ar -x libstdc++6_8.3.0-6_amd64.deb tar -xvf data.tar.xz cp usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25 /usr/lib64/find / -name "libstdc++*"
删除低版本库的软连接
rm -rf /usr/lib64/libstdc++.so.6 ll /usr/lib64/libstd* ln -s /usr/lib64/libstdc++.so.6.0.25 /usr/lib64/libstdc++.so.6
再次查看node版本,更新成功
v20.15.1
文章来源:
不凡
版权声明:本站所发布的全部内容源于互联网搬运,仅供用于学习和交流,如果有侵权之处请第一时间联系我们删除。敬请谅解! E-mail:xujinxiao@126.com
还木有评论哦,快来抢沙发吧~