Install node in Amazon Linux 2
Asked Answered
W

2

6

I purchased Amazon Linux 2 machine using AWS LightSail and tried to install node on that machine. But after several tries I can't able to install node and got the error shared below.

[root@ip-my public ip /]# sudo yum install nodejs
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 2:18.3.0-1nodesource will be installed
--> Processing Dependency: libc.so.6(GLIBC_2.28)(64bit) for package: 2:nodejs-18.3.0-1nodesource.x86_64
--> Processing Dependency: libm.so.6(GLIBC_2.27)(64bit) for package: 2:nodejs-18.3.0-1nodesource.x86_64
--> Finished Dependency Resolution
Error: Package: 2:nodejs-18.3.0-1nodesource.x86_64 (nodesource)
           Requires: libc.so.6(GLIBC_2.28)(64bit)
Error: Package: 2:nodejs-18.3.0-1nodesource.x86_64 (nodesource)
           Requires: libm.so.6(GLIBC_2.27)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Thanks in advance!

Womb answered 8/6, 2022 at 11:24 Comment(3)
this answer might helpArmendariz
@medbenzekri thanks for the help, but I got the same errorWomb
Got the same error today.Cling
W
13

I think AWS LightSail Amazon Linux 2 supports node version <=16.x, So we want to install node version <=16, I installed node version 16 and it works!!

Here are the steps followed,

Step 1:- Configure Yum Repository

$ sudo yum install -y gcc-c++ make 
$ curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -

Step 2:– Install Node.js on Amazon Linux

$ sudo yum install -y nodejs 

Step 3 – Check Version

$ node -v  
$ npm -v
    
Womb answered 17/8, 2022 at 8:57 Comment(3)
Also see stackoverflow.com/a/74298148Borrow
And AWS docs: setting-up-node-on-ec2-instanceBorrow
"Amazon Linux 2 does not currently support the current LTS release (version 18.x) of Node.js" :(Edi
A
11

My solution to fix this problem, you must erase cache with this command:

sudo rm -R /var/cache/yum/x86_64/2/nodesource/

Now, you can download the correct version:

curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -

And now you can install:

sudo yum install -y nodejs
Annabelannabela answered 20/12, 2022 at 4:6 Comment(1)
Removing the cache was the solution for meThomson

© 2022 - 2024 — McMap. All rights reserved.