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.

Note: You’ll need root access to follow the steps below.

NVM RPM

Install Node.js using nvm

Node.js developers recommend using Node Version Manager (nvm) to install Node.js.

  1. Login SSH
  2. Install nvm, you can use the install script using cURL:
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
    or Wget: wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
  3. Type command -v nvm to verify the installation succeeded
  4. Type nvm install node # for the latest version or nvm install [preferred version number]
  5. List installed Node.js versions with nvm ls-remote
  6. Open the console with nvm use node
  7. To open the Node.js console and verify Node is running, run node
  8. Run console.log(“Hello, World!”); which should return:
    Hello, World!
    undefined
  9. Type Control + 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. Login 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 console.log(“Hello, World!”); which should return:
    Hello, World!
    undefined
  7. Type Control + 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!

Thoughts on “Install Node.js

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

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

  • 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:

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

  • 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?

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

     

     

  • 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

    • 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

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

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

Leave a Reply to Tim Cancel reply