Node.js is an open-source JavaScript runtime environment. It is used to develop scalable networking and real-time web applications. Node.js built on Chrome’s high-performance V8 JavaScript engine. Node.js is noticed for its capacity to handle multiple concurrent connections.
Node.js uses a non-blocking, an event-driven, input-output model. This property makes the node.js as a lightweight process.
In this article, you will find how to run node.js on hosting and NPM on a shared hosting account.
Many users who have cheap node js hosting plans want to install or run node.js on hosting, this is a common query for all users.
Website owners need to run various JavaScript tasks on shared hosting. So in this article, you will find a short step by step guide to run node.js on hosting.
To run node.js on the hosting server, you need SSH access. For SSH access you need to ask your web hosting provider to enable SSH on your account, or you can obtain SSH access by using the following steps.
What is SSH?
SSH is a Secure Shell protocol that is used to provide secure command-line access to your web hosting account. By using SSH protocol, you can remotely log in to your web hosting account and can use it to run commands as if you were sitting right at the server.
Obtain SSH Access
The first thing you need to run node.js on shared hosting is SSH access to the server. Some web hosting providers allow jailed SSH access upon website owner’s request, some offer SSH access by default. For the login process, you might need to post a ticket.
Once you get SSH access you can log in by using Putty on Windows or your Terminal on a Mac.
How To Obtain SSH Access on cPanel Shared Hosting Server.
Step 1:
First, you need to log into your cPanel account and click on “SSH/Shell Access”.
Step 2:
Under “generate new SSH key pair” fill the form and be sure you choose a strong key password.
Step 3:
Now you need to click on “Generate”, tab and in the empty text file copy-paste the “Private Key” and then save it on your computer.
Step 4:
On Windows OS, you need to install Putty
(https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)
Step 5:
Once you are done with the installation process, run puttygen.exe and click on the “Load an Existing Private Key File”.
Step 6:
In the bottom-right corner choose all files from the dropdown dialog. Select the private key that you have saved at step no 4 and save it in a format that is (*.ppk).
Step 7:
Fire up Putty and from the left panel select
Connection -> SSH ->Auth
Step 8:
Using the Browse dialog select the *.ppk file and get back to the Session screen.
Step 9:
Now you need to type the hostname or IP of the server and port and now click to connect, type your cPanel username.
Install NVM and Install Node.js on cPanel
1. Go to the “NVM repository” and find out the latest version number.
Then put the NVM version in the below command by replacing VERSION_NUMBER with the most recent version number from Github and execute the command:
Curl~
https://raw.githubusercontent.com/creationix/nvm/VERSION_NUMBER/install.sh | bash.
2. If it successfully installed, you will get a group of messages that shows how to initially configure NVM. Now need to load NVM by using below command:
source ~/.bashrc
3. Finally installation of Node.JS is done by running below command:
nvm install –lts
This command will install the latest version of Node.JS and NPM.
4. To test node.js running or not type below command:
nvm use –lts
and then you can get
node -v
This will be used to find out the installed version of node.js.
Common Challenges:
1. If you get an error during run node.js on hosting server then you need to install an older version of Node.js
2. To do that, execute
nvm ls-remote –lts
That command shows you support Node.js versions that exist in the repository.
How to Select a Node.js Hosting Provider:
Node.js is a somewhat new concept, so most web hosting providers does not support it.
Nowadays it is also very popular, so many reliable low cost web hosting providers are well-optimized for Node.js applications.
Compare hosting options in detail before selecting hosting provider.
Factors to Consider:
Here are some of the factors you should consider before purchasing node.js server hosting:
- Which programming languages does the host support
- Ensure that the user-friendliness of your host matches your skillset
- Are other alternatives such as PHP more suited to your needs
- Are they provide high uptime and reliability?
Some specifics that you should consider when looking for a Node.js hosting plan:
- Pricing and cost-effectiveness
- Node.js versions supported
- Technical Support and Customer Service
- Hosting company reputation and reliability.
Conclusion:
In this article, we have seen steps to run node.js on the hosting server very easily with some commands.