Problem
You may encounter the following error while installing Node.js on Linux under an Amazon EC2 instance:
node: /lib64/libm.so.6: version GLIBC_2.27′ not found (required by node)
node: /lib64/libc.so.6: version GLIBC_2.28′ not found (required by node)
Reason
The reason for these issues is that your machine is running ldd (GNU libc) version 2.26 by default. If you are installing Node.js LTS version 18 or above, you will encounter these errors.
Solution
tl;dr
Install node 16 instead of LTS
Here are the steps to install Node.js using NVM on your EC2 instance:
- Update the package manager’s cache:
sudo yum update - Install the dependencies required for NVM:
sudo yum install -y gcc-c++ make - Download and install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash - Activate NVM by sourcing the
~/.bashrcfile:source ~/.bashrc - Install the LTS version of Node.js using NVM:
nvm install 16 - Set the installed Node.js version as the default:
nvm alias default stable - Verify the installation by checking the Node.js and npm versions:
node -v npm -v
By following these steps, you will have installed Node.js on your EC2 instance using Node Version Manager (NVM).