How to install Node.js & NPM using yum on Amazon Linux?

I’ve worked with Amazon Linux for a while, and the easiest way to get Node.js and NPM up and running is through the amazon-linux-extras repository. No hassle, just a few commands!

:one: First, check if Node.js is available:

amazon-linux-extras list | grep nodejs

This will show available versions, such as nodejs16 or nodejs18.

:two: Enable the required Node.js version:

sudo amazon-linux-extras enable nodejs18

:three: Now, install Node.js and NPM:

sudo yum install -y nodejs

:four: Verify the installation:

node -v
npm -v

And that’s it! With yum install nodejs, you get Node.js and NPM installed in minutes—no need to build anything manually. :rocket: