In this guide I’ll show you how to install Node.js on either your VPS or dedicated server. Node.js is a server-side JavaScript framework built off the V8 JavaScript engine from Google Chrome that allows for event-driven, asynchronous I/O requests to help handle a large amount of concurrent requests efficiently. The best method to install Node.js depends on whether you’re using a cPanel server or unmanaged cloud server.
You’ll need root access to follow the steps below.
Install Node.js on cPanel Hosting
- Log into WebHost Manager (WHM).
- Open EasyApache 4 (EA4).
- Under “Software,” select “Customize.”
- Select “Additional Packages.”
- Select the “nodejs10” toggle switch so it turns blue and displays “Install” to the right.
- On the left select “Review.”
- At the bottom select “Provision.”
Install Node.js using NVM
For Cloud Server Hosting and Bare Metal Dedicated Server Hosting, Node.js developers recommend using Node Version Manager (nvm) to install Node.js.
- Log into SSH
- Install nvm, you can use the install script using cURL or Wget:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
- Verify the installation succeeded:
command -v nvm
If you don’t receive output stating “nvm,” restart your server (shutdown -r) and try again.
- Type
nvm install [preferred version number]
or install the latest version:nvm install node #
- List installed Node.js versions:
nvm ls-remote
- Open the console:
nvm use noyour hosting plande
- To open the Node.js console and verify Node is running, run
node
- Run this test command:
console.log("Hello, World!");
Which should return:
Hello, World!
undefined - Type Ctrl + D to exit Node
Install Node.js using RPM
Those who prefer official Red Hat package manager (RPM) repositories can use the steps below.
- Log into SSH
- Download Node.js version 10 Long-Term Support (LTS) by running:
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
For Node.js v11, run:
curl -sL https://rpm.nodesource.com/setup_11.x | bash -
- To install Node.js, run:
yum -y install nodejs
- To ensure the developer tools needed for npm development are installed, run:
yum install gcc-c++ make
- To open the Node.js console and verify Node is running, run:
node
- Run this test command:
console.log("Hello, World!");
Which should return:
Hello, World!
undefined - Type Ctrl + D to exit Node
You should now have a successful installation of Node.js running, and in further guides we’ll go more in-depth with some of the amazing things you can do with Node.js!
Enjoy high-performance, lightning-fast servers with increased security and maximum up-time with our Secure VPS Hosting!
Linux VPS cPanel or Control Web Panel Scalable Website Migration Assistance
Hi InMotion team,
I am currently trying to follow this guide on my VPS and am getting the following error trying to install nvm:
=> Downloading nvm from git to ‘/root/.nvm’
=> Cloning into ‘/root/.nvm’…
fatal: unable to access ‘https://github.com/creationix/nvm.git/’: Problem with the SSL CA cert (path? access rights?)
Failed to clone nvm repo. Please report this!
The same SSL CA cert error shows when I try to use curl instead. I am SSH-ed into the VPS via the root account so it doesn’t feel like a permission issue. However, when I try to run the command from my local Mac (without being SSH-ed in) it works just fine.
Any help would be appreciated!
Thanks,
Tobias
It’s interesting that it works in the Mac environment and not in your VPS. I’d advise logging into WHM to see if any updates need to be applied. Otherwise, I’d recommend getting some time with our Managed Hosting team. They can make custom configurations for you.
Can Node.js coexist with good ol’ apache / php server? What would be the impact in the already present sites?
Node.JS and a PHP-based can run together on a server. There are some definite pros and cons. Check out this article on the subject. It does a good job of summarizing the issue.
The best way to get around the g++ version issue is to install and use devtoolset-6. Very easy instructions included at the link.
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-6/
Nice article ! i have a resller account nd i want to install node js . when i login to AMP i didn’t found the root user config so i have one question is reseller account support installing node js ? thnk’s in advance
Hello! Our reseller accounts do not include root access. A VPS/Dedicated server is required for installation of node.js. I hope this helps.
Sincerely,
Carlos E
This works and much easier that the above steps which also created a problem for me. It’s much faster, and npm also installs.
Hi guys,
I tried the above tutorial that is excellent, but i could not get the build to compile through the wget installation. So, being on CentOS (VPS plan), I did something a little different that worked. I am hereby sharing it, so just in case somebody needs it, they can also try it.
As root:
Im getting the same problems as others
root@ded [/usr/local/src/node-v7.2.0]# yum list installed | egrep “openssl-devel|python26|python27|gcc-c++”
gcc-c++.x86_64 4.4.7-17.el6 @base
openssl-devel.x86_64 1.0.1e-48.el6_8.3 @updates
At step 7
WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++)
then if I try to update the compiler I get
Package gcc-c++-4.4.7-17.el6.x86_64 already installed and latest version
So basically at a standstill.
Hi, I am following the steps trying to install node.js, however when y get to the line:
python2.6 configure , I get this warning:
WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++)
creating icu_config.gypi
But acoording with the support team the gcc 4.8 is already installed but in a very strange and hard to find folder, could you please tell me what can I do to go ahead with the installation using that folder? or should I install is some where else?
Thanks a lot
I checked the python version and told me 2.6.6!
when i type node it told me command not found…..
Then i try to install nodejs but it doesn’t works… what i missed?
regards,
Marwan
Did you run the command: yum list installed | egrep “openssl-devel|python26|python27|gcc-c++”
If so, what was your output?
Saved me hours of work. Great Work
Hello.
I have a pro plan. Can I install Node.js or should I upgrade?
Hello Vaggouras,
To install Node.js you have to be on a VPS or higher. You will need to upgrade accordingly.
Thanks!
Tim S
I guess I forget to include the link to the build instruction for CouchDb. You can find them here:
https://www.tecmint.com/install-apache-couchdb-in-rhel-centos-debian-and-ubuntu/
I just tried this and got the same error as Lindsey Bohland. The instructions at her link did bring much joy though, so she has my gratitude and admiration. And, fwiw, these install instructions for CouchDB on CentOS 6.7 also worked for me today, so my joy was doubled with Lindsey’s post here. Thank you all for sharing!!!
Yes indeed. Things are successful until I run python2.6 configure, which returns the following error:
WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++)
I followed the steps on this page and was able to get node running. https://krisreeves.com/code/compile-node-js-4-0-on-centos-6/
Have these instructions been tested on CentOS 6.7? I’m getting errors at step 7. Wondering if the newer CentOS version coupled with gcc 4.4 might be a problem…
Hello Lindsey,
No these steps have not been tested on CentOS 6.7 at this time. Are you getting errors during the installation?
Best Regards,
TJ Edens
No, just show one jump of line
Hello Kelvin,
Odd, we did not have that experience. Since I cannot duplicate I can only take a stab at it. Here is a link to a help article, it is on a MAC device, but the situation could possibly help you as well.
Kindest Regards,
Scott M
Hi Scott,
Yes, I install nodejs and npm, when I execute the command npm install forever, dont shows the action.
Is there any error message that appears?
Good day.
I installed nodejs according to the tutorial, I want to run npm and shows no options.
What did I do wrong?
Thank you very much for your help.
Hello Kelvin,
Did you install npm after installing node?
Kindest Regards,
Scott M
Does npm work on inmotion VPS with nodejs installed? What about github integration?
Thanks
Naga
Hello Naga,
Yes npm works and you can install git as well to incorporate githubs repos.
Best Regards,
TJ Edens
How do you set it up so if the server reboots it will auto start?
Hello Dustian,
Thanks for the question! This is not an uncommon question with the Node.JS community. They recommend either an “upstart” script (Linux) or something called “Forever”. You can find the particulars discussed here (how to automatically restart a node server) . There are other options as well, but you can find them by using your favorite search engine. I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
Just to concur with Jim B – I also had problems connecting as an outside user (via multiple proxies) but no problem connecting from my static IP, because the IP is allowed for root access. I had to edit the apf file to add the relevant port so, if anyone gets stuck, this link is your friend: https://www.inmotionhosting.com/support/website/general-server-setup/how-to-open-a-port-in-your-firewall
Thanks to Scott M. You have shared useful info about installing Node.js.
I would like to add that the above instructions worked perfect. After many hours of experimenting with my server.js file and index.html files accessing an MYSQL DB, locally I was able to get it to work in a web browser, (VPS Hosting). Others around the country trying through the index.html I created would connect but not receive any data from the SQL DB. Unable to resolve after several days of trying I contacted support via chat. Thanks to the excellent support team (Chris R) he suggested:
Open Ports in APF:
https://www.inmotionhosting.com/support/website/general-server-setup/how-to-open-a-port-in-your-firewall
Followed the instructions in the link he gave, I added the port I wanted to use. Everything is working perfect now across the country and locally, including over 3g and 4g. There are many examples on the internet on how to utilize node.js and no one seems to pick the same port for their examples for listening or sending so this threw me off even more. I hope this info helps someone and saves them hours of troubleshooting.
As a side note: I had asked Chris R what port does Inmotion or you recommend to use, he responded: “I have found in online references that 8124 is the common port used although you can set up custom ports on VPS platform if needed” I did use another port but might switch it to 8124.
Great nodejs installation guide!!! Super useful!
Cheers!
Great article – Thanks.
Is it possible that Node can be installed by a domain user for a particular domain that has SSH access, so thay can install packages like Grunt and build a workflow without having to do it as root.
Hello Neil,
Installing node.js unfortunately needs to be done with the root user. Even with SSH access they would nee the root level permissions.
Kindest Regards,
Scott M