Linux配置nodejs和nvm遇到的问题
环境:centos7
某些项目的环境依赖node和npm,不同项目和系统的版本不同,所需要的node版本也不一样;某些工具的安装使用yum无法完成,所以还得下载了npm用npm来安装。
所以node、npm或者node版本管理工具nvm的安装还是必要的。
nvm
.nvm./install.sh.bashrc.bash_profile
glibc和glibcxx版本与node版本不兼容
问题描述
my nvm version is 0.38.0,but when i input node or npm, shows :
1 | node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node) |
解决方案(来自newbing):
I’m sorry to hear that you are having trouble with node and npm on CentOS. This error means that your system does not have the required versions of the GNU C Library (glibc) and the GNU Standard C++ Library (libstdc++) that node and npm depend on¹. There are a few possible ways to fix this error:
- You can try to install an older version of node and npm that is compatible with your system’s glibc and libstdc++ versions. You can use nvm to switch between different node versions easily². For example, you can run
nvm install 10to install node 10, which should work with glibc 2.17 and libstdc++ 4.8.5³. - You can try to update your system’s glibc and libstdc++ libraries to the latest versions. This may require you to upgrade your CentOS version or use a third-party repository⁴. For example, you can run
sudo yum install centos-release-sclandsudo yum install devtoolset-9-gcc-c++to install glibc 2.28 and libstdc++ 9.2.1 from the Software Collections Library (SCL) repository⁵. - You can try to install node and npm from source code. This will allow you to compile them with your system’s glibc and libstdc++ versions. However, this may take longer and require more dependencies⁶. For example, you can run
curl -O [7](https://nodejs.org/dist/v18.0.0/node-v18.0.0.tar.gz)andtar xvf node-v18.0.0.tar.gzto download and extract the node source code, and then runcd node-v18.0.0and./configure && make && sudo make installto build and install node and npm.
I hope one of these options works for you. If you need more help, you can check out some of the web resources I found for you. Good luck! 😊
yum 安装 npm遇到问题
问题描述
1 | This system is not registered with an entitlement server. You can use subscription-manager to register. |
解决方案
停止掉该插件的使用,在配置文件中让enable=0即可。
报错的意思是:操作系统需要注册,你可以使用订阅管理器来注册系统。
Redhat需要操作系统注册后才能使用yum。把这个插件的功能关掉,就行了。
yum源调用订阅管理器插件(其实是一个脚本)
/usr/lib/yum-plugins/subscription-manager.py
这个脚本中定义了订阅管理器的配置文件:/etc/yum/pluginconf.d/subscription-manager.confshell
1
2 [main]
enabled=1
用vi编辑把这个值改成0 就行。
————————————————
原文链接:https://blog.csdn.net/maibaizhou/article/details/121047462
npm安装其他库遇到问题
问题描述1
1 | npm install tldr |
报错:
1 | npm ERR! code ECONNREFUSED |
解决方案1
再试一次好像就成功了()

