5

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!

Sarvath S
  • 197
  • 3
  • 9

2 Answers2

14

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
    
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Sarvath S
  • 197
  • 3
  • 9
  • Also see https://stackoverflow.com/a/74298148 – djvg Nov 25 '22 at 15:32
  • 1
    And [AWS docs: setting-up-node-on-ec2-instance](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-up-node-on-ec2-instance.html) – djvg Nov 25 '22 at 15:33
  • "Amazon Linux 2 does not currently support the current LTS release (version 18.x) of Node.js" :( – Ryan Pfister Jun 02 '23 at 18:09
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
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Leonel Pech
  • 121
  • 1
  • 2