node.js安装(linux)
环境:
Os:Centos 7
1.官网下载
地址地址:
https://nodejs.org/en/download/prebuilt-binaries
node-v20.14.0-linux-x64.tar.xz
选择相应的版本和操作系统
2.解压安装
tar -xvf node-v20.14.0-linux-x64.tar.xz
mv node-v20.14.0-linux-x64 /opt/node-v20.14.0
3.添加环境变量
vi /etc/profile
export NODEJS_HOME=/opt/node-v20.14.0
export PATH=$NODEJS_HOME/bin:$PATH
4.重新登录
[root@dsc1 bin]# npm -v
node: /lib64/libm.so.6: version `GLIBC_2.27' 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 `CXXABI_1.3.9' not found (required by node)
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
解决办法:
安装与当前系统匹配的版本,我这里安装如下版本是可以的
node-v17.9.1-linux-x64.tar.xz
[root@dsc1 bin]# ./node -v
v17.9.1
重新添加环境变量
vi /etc/profile
export NODEJS_HOME=/opt/node-v17.9.1
export PATH=$NODEJS_HOME/bin:$PATH
[root@dsc1 ~]# node -v
v17.9.1