NPM Error in WHM, Saved by Installing NVM

So i ran NPM in my centos server. But accidentally i upgraded NPM from old version to the latest version (i forgot what command that i ran).

After that, all command using “npm” were broken. It said i need to use newer node (at that time i used node 10.24.1).

I had 2 options :

  1. Upgrade my node to the latest version.
  2. Downgrade my NPM to the old version.

First, let’s try upgrade the node. I tried to update node to version 16 with EasyApache 4. However npm was still failed because somehow it detected the node was still version 10.24.1.

It seems somehow i couldn’t upgrade my node / used the latest node in my server (maybe i misconfigured something).

So let’s try second option, downgrading the NPM.
But I couldn’t even uninstall NPM. All commands started by npm were totally failed.

Then i tried to uninstall npm manually.
First i tried to find out where the npm was. i ran which npm and whereis npm.

[x@y zzz]# which npm
[x@y zzz]# whereis npm
npm: /usr/bin/npm /usr/share/man/man1/npm.1

Found it ! /bin/npm

Then i renamed it as backup instead of deleting it, just in case something bad happened

mv /bin/npm /bin/npm_backup

I wanted to reinstall NPM (and node) with NVM, because :

If you use nvm to install Node.js, it will automatically install a compatible npm version with it. You don’t need to manually reinstall npm if you’re using nvm to manage your Node.js versions.

Then i installed NVM

curl -o- | bash

Finally NVM was installed

[x@y zzz]# nvm

Node Version Manager (v0.39.5)

But then i got new error

[x@y zzz]# node -v
node: /lib64/ version `GLIBC_2.27' not found (required by node)
node: /lib64/ version `GLIBCXX_3.4.20' not found (required by node)
node: /lib64/ version `CXXABI_1.3.9' not found (required by node)
node: /lib64/ version `GLIBCXX_3.4.21' not found (required by node)
node: /lib64/ version `GLIBC_2.27' not found (required by node)
node: /lib64/ version `GLIBC_2.28' not found (required by node)
node: /lib64/ version `GLIBC_2.25' not found (required by node)

What Chat GPT said

The errors you’re encountering are because the versions of GLIBC (GNU C Library) on your system are older than what the installed version of Node.js requires. Node.js is compiled against newer versions of GLIBC that aren’t present on your CentOS system.

Then i tried to install specific version of node which was 10.24.1. That version should works because that was the version that i remembered when node & npm were working.

nvm install 10.24.1

[x@y zzz]# node -v
[x@y zzz]# npm -v

Finally i can run NPM (and node) again in my server.

Leave a Reply

Your email address will not be published. Required fields are marked *