安装nvm(内容出处:https://www.cnblogs.com/wafulo/p/17581766.html)
1.下载安装包
wget https://github.com/nvm-sh/nvm/archive/refs/tags/v0.39.1.tar.gz
2.创建安装包解压目录
mkdir -p /root/.nvm
3.解压安装包到目录
tar -zxvf nvm-0.39.1.tar.gz -C /root/.nvm
4.进入到解压目录
cd /root/.nvm/nvm-0.39.1
5.执行安装脚本
sh install.sh
6.重新加载用户配置
source ~/.bashrc
7.尝试使用nvm命令,验证是否成功
nvm list
8.根据nvm list展示的node版本,安装对应版本
nvm install v20.12.1
9.切换node版本
nvm use 20.12.1
11.centos7服务器安装node之后,使用npm或者node,会出现以下问题
npm -v
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)
===================切换源、升级包==================
1.替换一些源
(图片出处:https://www.cnblogs.com/riverhan/articles/18298541)
处理:
cd /etc/yum.repos.d/ 找到 CentOS-SCLo-scl.repo 和 CentOS-SCLo-scl-rh.repo
将里面的 mirrorlist= 注释掉,再将baseurl= 取消注释,并把baseurl的域名地址改为阿里云 https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
升级(内容出处:https://www.cnblogs.com/chenlifan/p/18159932)
2.升级gcc与make
# 升级GCC(默认为4 升级为8)
yum install -y centos-release-scl bison
yum install -y devtoolset-8-gcc*
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
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
3.更新libstdc++.so.6.0.26
# 更新lib libstdc++.so.6.0.26
wget https://cdn.frostbelt.cn/software/libstdc%2B%2B.so.6.0.26
# 替换系统中的/usr/lib64
cp libstdc++.so.6.0.26 /usr/lib64/
cd /usr/lib64/
ln -snf ./libstdc++.so.6.0.26 libstdc++.so.6
4.更新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
make && make install
===================验证==================
1.验证
npm -v
node -v
(吐槽CSDN,支持开源)
标签:node,20,centos,make,usr,so.6,nvm,lib64 From: https://www.cnblogs.com/pang-py/p/18658986