Casbay Knowledge Base

Search our articles or browse by category below

5 Easy Node.js Installation Steps to Follow For Your Linux VPS Server

Last modified: February 15, 2022
You are here:
Estimated reading time: 1 min

Node.js is an advanced development framework especially for hosting websites. It has proven its own worth by getting high usages in multiple areas such as browser games, chat applications, back-end tools, and more. Node.js is so commonly used in websites that it is likely that most people who owned a VPS will need Node.js. This is due to how most VPS were also used for web hosting, so here is what you need to know on how to install Node.js for your Linux VPS server. This guide works on every Linux operating system.

Step 1: Download Node.js archive

To make sure you are located in the home directory, use the following command.

cd ~

After being positioned into the home directory, use the following command to download your desired Node.js archive. Do note that you can choose a specific version of Node.js by changing the URL in the command below.

wget https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz

Step 2: Extract the downloaded Node.js archive

Use the following command to extract the downloaded Node.js archive.

tar xvf node-v14.18.1-linux-x64.tar.xz

You can find a new directory created where it is named node-v14.18.1-linux-x64.

Step 3: Rename the directory

This step is optional for your installation. However, it will make the installation process more simplified due to amount of times the file name will be repeated in the commands and also a cleaner name for the folder. Skip this step if you deem it unnecessary. To simplify the directory name from node-v14.18.1-linux-x64 to node, use the following command.

mv node-v14.18.1-linux-x64 node

Step 4: Install both Node.js's and npm's binaries

In this step, we will have 4 sub-steps. First, we will make a binaries folder and name it bin. You can follow the command below to create the folder.

mkdir ~/bin

Then, copy all the binaries from the node folder to the new directory created earlier. Use the following command for this step.

cp node/bin/node ~bin

Then direct to the new directory using the command below.

cd~ bin

Finally, create the necessary symbolic links with the following command.

ln -s ../node/lib/node_modules/npm/bin/npm-cli.js npm

Step 5: Verifying installation

To confirm that both Node.js and npm were installed on the server and what versions were installed, use the following commands.

The command for Node.js version:

node -v

The command for npm version:

npm -v

You should be able to see the version of both Node.js and npm respectively. If any of them doesn’t show up, then it means the installation fails, retrace the steps above and install them again.

Was this article helpful?
Dislike 0
Views: 8