Installing Node.js and npm on Amazon Linux Using Yum
Running applications using Node.js on Amazon Linux is a common requirement among developers. The process should ideally be straightforward, allowing you to focus more on development rather than environment setup. This post will guide you through efficiently installing Node.js and npm on Amazon Linux using the yum
package manager.
Amazon Linux provides access to multiple repositories for installing and managing software packages. The most common method for adding software not included in the base repository is through the Extra Packages for Enterprise Linux (EPEL) repository. This community-supported repository provides high-quality software packages, including those for Node.js and npm.
Step-by-Step Installation Guide
Here’s how you can quickly set up Node.js and npm:
-
Enable the EPEL Repository:
- To access the EPEL repository directly through yum, you need to enable it. This repository holds packages that might not be available in default Amazon Linux repositories.
-
Install Node.js and npm:
- Use the command below to install Node.js along with npm. This leverages the EPEL repository to fetch the necessary packages:
sudo yum install nodejs npm --enablerepo=epel
- This command ensures that you get a version of Node.js that is stable and compatible with your setup.
- Use the command below to install Node.js along with npm. This leverages the EPEL repository to fetch the necessary packages:
-
Verifying the Installation:
- After installation, verify that Node.js and npm are correctly installed by checking their versions:
node -v npm -v
- If these commands return the respective version numbers, you are all set to begin using Node.js on your system.
- After installation, verify that Node.js and npm are correctly installed by checking their versions:
Understanding EPEL: EPEL (Extra Packages for Enterprise Linux) is a repository created by the Fedora project, offering additional packages for frequently-used software on RHEL/CentOS and their derivatives like Amazon Linux. These packages often include tools and libraries not available in the default repositories, expanding the available software by significant amounts.
Considerations
If you are running Amazon Linux 2, the built-in repositories often include a more recent version of Node.js. In such cases, the EPEL repository may not be needed unless you are specifically targeting older or development versions of Node.js that might not be present in those default repositories.
Additionally, always keep your system updated with yum update
to ensure all dependencies and packages are current, avoiding compatibility issues.
By following these straightforward steps, you ensure a hassle-free installation of Node.js and npm, aligning with updated Linux and AWS best practices. This setup enables a robust environment for Node.js applications, allowing you to spend your time on what truly matters—writing excellent code.