Install Node.js and NPM on hosting server

Install Node.js and NPM on hosting server

This blog will show, how to setup Node.js and NPM on your managed hosting server. We are going to host in Linux server.

Before moving forward, please keep your SSH credentials in hand. We are going to use SSH tool to install Node.js and NPM.

Prerequisites

  • Your hosting account must have SSH (not jailshell) enabled. To check which shell your account is using, login your SSH account and type the following command:

  • Node.js currently only works on servers running CentOS 6 or CentOS 7. To check the version of CentOS on your server, log in to your account using SSH, and then type this command:

If the output from this command contains el6 (for example, 2.6.32-531.17.1.lve1.2.60.el6.x86_64) or el7 (for example, 3.10.0-714.10.2.lve1.5.12.el7.x86_64) , then your server is running CentOS 6 or CentOS 7.

However, if you see el5h (for example, 2.6.32-531.23.3.lve1.2.66.el5h.x86_64), then your server is running CentOS 5 and does not support Node.js. Please contact your hosting provider.

Installing Node.js and NPM

  • After your account meets the installation prerequisites, you can download and install Node.js and NPM (the Node.js package manager). To do this, follow these steps:

This will save node.js package on your server directory.

  • To extract the Node.js files, type this command:

  • To rename the extracted folder to the more convenient nodejs name, type this command:

  • To install the node and npm binaries, type these commands (may not be a required step in your setup):

  • After you run these commands, Node.js and NPM are installed on your account. To verify this, type these following commands:

The ~/bin directory is in your path by default, which means you can run node and npm from any directory in your account.

Creating your Node.js application on server

After successful installation of Node.js and NPM on your service, next step is create a node.js application. So, I have created a subdomain services.zeptobook.com, and put the node.js app there.

Create a server.js file on local, and upload it to the subdomain directory.

server.js

Now, go to SSH terminal, and go to your subdomain directory, and run this command.

Now, go to the PostMan tool, and access your service url.

service call

This is how, you can setup Node.js and NPM on your linux server.

Summary

In this blog, we learned about setting up Node.js and NPM on Linux hosting server.

Read more:

Adesh

Hi, I am Adesh. I am a senior software engineer having more than 12 years of software development experience. I am a full stack developer and interested in writing the technical post on programming. I am currently working in New York City area.

This Post Has 4 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu