How Do You Install npm and Node.Js on Any Distribution of Linux?

Problem scenario
You have Linux servers of different distributions (including Debian/Ubuntu, Red Hat derivatives such as CentOS, RHEL, or Fedora, and Linux SUSE).  You want to install npm and Node.js on them.  What do you do?

Solution
Prerequisites
i.  You need a server with at least 1 GB of RAM.  To add virtual memory, see this posting.  To resize your GCP server, see this posting.  To upgrade your EC-2 instance (a VM running in AWS), see this posting.
ii.  Install the C compiler.  If you do not know how, see this posting.

Procedures
1.  Create a file named "npminstaller.sh" (with no quotes) with the following content:

cd /opt/
curl http://nodejs.org/dist/v14.1.0/node-v14.1.0.tar.gz > node-v14.1.0.tar.gz
tar xzvf node-v14.1.0.tar.gz && cd node-v14*
./configure
make
make install

2.  Run the script with "sudo bash npminstaller.sh" with no quotes.  This script may take over one hour to run.

Leave a comment

Your email address will not be published. Required fields are marked *