How to Install Node.js

How to Install Node.js

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

  1. Log into WebHost Manager (WHM).
  2. Open EasyApache 4 (EA4).
  3. Under “Software,” select “Customize.”
  4. Select “Additional Packages.”
  5. Select the “nodejs10” toggle switch so it turns blue and displays “Install” to the right.
    Install nodejs10 in EasyApache 4
  6. On the left select “Review.”
  7. 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.

  1. Log into SSH
  2. 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
  3. Verify the installation succeeded:
    command -v nvm

    If you don’t receive output stating “nvm,” restart your server (shutdown -r) and try again.

  4. Type nvm install [preferred version number] or install the latest version:
    nvm install node #
  5. List installed Node.js versions:
    nvm ls-remote
  6. Open the console:
    nvm use noyour hosting plande
  7. To open the Node.js console and verify Node is running, run
    node
  8. Run this test command:
    console.log("Hello, World!");

    Which should return:
    Hello, World!
    undefined

  9. 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.

  1. Log into SSH
  2. 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 -
  3. To install Node.js, run:
    yum -y install nodejs
  4. To ensure the developer tools needed for npm development are installed, run:
    yum install gcc-c++ make 
  5. To open the Node.js console and verify Node is running, run:
    node
  6. Run this test command:
    console.log("Hello, World!");

    Which should return:
    Hello, World!
    undefined

  7. 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!

Secure VPS HostingEnjoy high-performance, lightning-fast servers with increased security and maximum up-time with our Secure VPS Hosting!

check markLinux VPS check markcPanel or Control Web Panel check markScalable check markWebsite Migration Assistance

Linux VPS Hosting

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

37 thoughts on “How to Install Node.js

  1. 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

    1. 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.

    1. 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.

  2. 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/

  3. 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

    1. 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

  4. This works and much easier that the above steps which also created a problem for me. It’s much faster, and npm also installs.

  5. 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:

    # curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
    # yum install -y nodejs

  6. 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.

  7. 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

  8. 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

    1. Did you run the command: yum list installed | egrep “openssl-devel|python26|python27|gcc-c++”

      If so, what was your output?

    1. Hello Vaggouras,

      To install Node.js you have to be on a VPS or higher. You will need to upgrade accordingly.

      Thanks!

      Tim S

  9. 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/

  10. 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!!!
     
     

  11. 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/

     

  12. 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…

    1. 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

    1. 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

  13. 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.

    1. Hello Naga,

      Yes npm works and you can install git as well to incorporate githubs repos.

      Best Regards,
      TJ Edens

    1. 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.

  14. 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

  15. 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.

  16. 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.

    1. 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

Was this article helpful? Join the conversation!

Server Madness Sale
Score Big with Savings up to 99% Off

X