GLIBC_2.27 not found while installing Node on Amazon EC2 instance - node.js

I'm trying to install Nodejs on Amazon linux machine, I'm following this documentation to install node https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html but I'm getting below error when I execute this command nvm install node
How can I fix this issue? Any help would be much appreciated. Thanks!
v18.0.0 is already installed.
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)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v18.0.0` to unset it.
[ec2-user#ip-xx-xxx-xx-xx ~]$ node -e "console.log('Running Node.js ' + process.version)"
-bash: node: command not found
I tried running this nvm use --delete-prefix v18.0.0 but no luck.

Try installing the active LTS version instead of latest with nvm install 16 (instead of nvm install node) as per the examples.
This was tested on the docker image amazonlinux:2 and correlates to what AWS CDK supports (ref)

It seems like you are using v.18.0.0 which was the latest but not well-supported.
Try uninstalling that.
nvm uninstall 18.0.0
Install a version that is active.
nvm install 16.0.0
You should now be using v16 which should be well-supported.

Amazon Linux 2 or some os includes glibc 2.26 or under.
To use a higher glib version,
you need to consider other AMI.
for example) Amazon Linux 2022. (al2022-ami) it includes glibc 2.34
reference : https://repost.aws/questions/QUrXOioL46RcCnFGyELJWKLw/glibc-2-27-on-amazon-linux-2

The error message:
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)
is telling you that you do not have a new enough version of glibc for nvm to install node 18. The error tells you it requires at least glibc 2.27.
You can find your current glibc version with: ldd --version
It's possible that you can install a newer version of glibc using a package manager like apt-get.
You can find the latest available version of glibc available via your package manager with: apt-cache policy libc6.
If your package manager can't install a new-enough version of glibc, you need to be on a newer version of your operating system. In Ubuntu, you can accomplish an OS upgrade with do-release-upgrade.

There is some issue with nvm latest version 18.x.x.
Try following steps to resolve the issue
1.Uninstall your nvm
$ nvm uninstall <nvm_version>
ie. $ nvm uninstall 18.12.2
2.Install stable version of nvm
$ nvm install <stable_nvm_version>
ie. $ nvm install 16.0.0

Related

Installing node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node) error on linux

I have followed this - How to install node.tar.xz file in linux
in the end while doing node --version I am getting these errors -
What should be done next here?, not able to find proper steps with respect to my scenario.
This error happens when you install Node on an operating system that has a version of GLIBC that is lower than Node can support. For example, Node v18 supports GLIBC v2.7 or later. When you attempt to install Node v18.x on any Linux OS that has GLIBC v2.6 or lower, you will get such errors.
To see the version of GLIBC that your operating system has, execute the ldd command on the terminal:
$ ldd --version
I can suggest three options to resolve this issue:
Either install Node from source code. This will allow you to recompile
Or install an older version of Node that your OS can support
Or upgrade your Linux OS to a newer version.
Reference: Install Node from source code

How to downgrade Node version

I want to downgrade my Node version from the latest to v6.10.3.
But nothing worked so far. Tried NVM and it gives an error as well by saying make command is not found. How can I downgrade Node?
Warning:
This answer does not support Windows OS
You can use n for node's version management. There is a simple intro for n.
$ npm install -g n
$ n 6.10.3
this is very easy to use.
then you can show your node version:
$ node -v
v6.10.3
For windows nvm is a well-received tool.
For windows:
Steps
Go to Control panel> program and features>Node.js then uninstall
Go to website: https://nodejs.org/en/ and download the version and install.
Determining your Node version
node -v // or node --version
npm -v // npm version or long npm --version
Ensure that you have n installed
sudo npm install -g n // -g for global installation
Upgrading to the latest stable version
sudo n stable
Changing to a specific version
sudo n 10.16.0
Answer inspired by this article.
In Mac there is a fast method with brew:
brew search node
You see some version, for example: node#10 node#12 ... Then
brew unlink node
And now select a before version for example node#12
brew link --overwrite --force node#12
Ready, you have downgraded you node version.
This may be due to version incompatibility between your code and the version you have installed.
In my case I was using v8.12.0 for development (locally) and installed latest version v13.7.0 on the server.
So using nvm I switched the node version to v8.12.0 with the below command:
> nvm install 8.12.0 // to install the version I wanted
> nvm use 8.12.0 // use the installed version
NOTE: You need to install nvm on your system to use nvm.
You should try this solution before trying solutions like installing build-essentials or uninstalling the current node version because you could switch between versions easily than reverting all the installations/uninstallations that you've done.
For windows 10,
Uninstalling the node from the "Add or remove programs"
Installing the required version from https://nodejs.org/en/
worked for me.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
sudo npm install -g n
sudo n 10.15
npm install
npm audit fix
npm start
If you're on Windows I suggest manually uninstalling node and installing chocolatey to handle your node installation. choco is a great CLI for provisioning a ton of popular software.
Then you can just do,
choco install nodejs --version $VersionNumber
and if you already have it installed via chocolatey you can do,
choco uninstall nodejs
choco install nodejs --version $VersionNumber
For example,
choco uninstall nodejs
choco install nodejs --version 12.9.1
If you are on macOS and are not using NVM, the simplest way is to run the installer that comes from node.js web site. It it clever enough to manage substitution of your current installation with the new one, even if it is an older one. At least this worked for me.
Try using the following commands
//For make issues
sudo apt-get install build-essential
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
//To uninstall a node version
nvm uninstall <current version>
nvm install 6.10.3
nvm use 6.10.3
//check with
node -v
Steps to downgrade to node8
brew install node#8
brew link node#8 --force
if warning remove the folder and files as indicated in the warning then again the command :
brew link node#8 --force
For windows users, you guys can downgrade using following commands.
npm uninstall -g node
npm install -g node#version
#version is your specified version, example : 12.22.3(little old)
Can find node releases here https://nodejs.org/en/download/releases/
I have used brew in mac to downgrade the node
follow the steps you will have the result:
brew search node (here you can see the version eg: node#10, node#12, node#14)
brew unlink node
brew install < node version > (eg: node#12)
brew link --overwrite node#12
If you are using nvm, following are the ways -
1. nvm install node_version
2. nvm use --delete-prefix node_version
For more insights, see this image -
Ubuntu:
nvm list
nvm use <version>
nvm list // Shows all the versions on your machine. Of course have your version installed.
nvm use // Use this version
it seems to be a compatibility issue, run
sudo n 14
then npm install or yarn install again. It will work
In case of windows, one of the options you have is to uninstall current version of Node. Then, go to the node website and download the desired version and install this last one instead.
I had to downgrade node to v10.16.0
sudo n 10.16.0
nvm use v10.16.0
this solved the problem for me
WINDOWS: Best way that you can do it and to not lose time.
Go to control panel
Uninstall Program
Uninstall node
Then go and find the version that you want to install, install it from the beginning.
Link with node versions: https://nodejs.org/uk/blog/release/
Here is a simple solution
Go to this link and download & install the suitable nvm setup on your computer
https://github.com/coreybutler/nvm-windows
Type nvm list to get list of installed node versions
Type nvm install <node-version>
Type nvm use <version>
here we go you got node version you want.
Browse here to find node versions => https://nodejs.org/en/download/releases/
The Node.js team suggests to use the following Node.js version managers to switch between different versions of Node:
OSX or Linux:
nvm
n
Windows:
nodist
nvm-windows
I personally made good experiences using "nvm-windows" on Windows 11.
I would recommend using NVS (Node Version Switcher).
You can see the source here and all you need is a package manager. Like Chocolatey or Homebrew.
Install it
choco install nvs
Add a version:
nvs add v16
Switch to any version you installed
nvs use v16
At the end if you "run node -v" you'll get the current you've switched.

How to upgrade the Node version to very latest using Ubuntu?

I need to upgrade the latest version of Node.js in my Ubuntu system. Is this latest version user-friendly ? I need the command to upgrade it using Ubuntu 14.04.
I suggest you install nodejs through nvm (node version manager), this way you can have various version at one time and can easily change what version you want
https://github.com/creationix/nvm
installing latest node should just be like this
nvm install node
or to install specific version
nvm install v4.5.0

How to install nodejs 4.1.2 with HomeBrew

I installed NodeJs with the following commands:
brew install node
It downloaded the version 5.5.0 of NodeJs.
I want the version 4.1.2 (for Ionic compatibility).
How to download this specific one?
I can't run brew switch node 4.1.2 since I've never downloaded it before.
May I suggest using nvm instead?
With nvm you can switch between node versions really easy:
nvm install 4.2
And you can install multiple versions of node and switch between them as you wish.
You can search available versions of node to install by running:
brew search node
The closest version would be "node4-lts". To obtain that version, run:
brew install homebrew/versions/node4-lts

I upgraded node but it still uses the wrong version?

I just ran brew upgrade node and it successfully upgraded Node to version >=4, however node --version returns the old version:
My-MacBook-Pro:~ me$ node --version
v2.3.0
My-MacBook-Pro:~ me$ brew upgrade node
Error: node 4.1.1 already installed
How can I have node use the newest version instead of 2.3.0?
First of all, did you run:
brew update
prior to:
brew upgrade
You could also try linking to the correct version:
brew switch node <version>
To see which versions of node homebrew knows about:
brew info node
If you are on a MAC (as you state) then i would highly recommend using NVM to manage your node and npm versions - and avoid homebrew for this altogether (especially if support for more than one version is likely). This is the best way to install node on a MAC imho.
The easiest way to upgrade from Node 0.12.x (io <4.x) to 4.x on OS X is by using the OS X installer from https://nodejs.org/dist/v4.2.4/node-v4.2.4.pkg.
It automatically symlinks all the required binaries.
brew unlink node followed by:
rm '/usr/local/include/node/common.gypi' followed by:
brew link --overwrite node
This fixed it for me.

Resources