node.jslinuxamazon-lightsailamazon-linux

Install node in Amazon Linux 2


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!


Solution

  • 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