Cloud Servers Help

Install Node.js - Fedora

Node.js is a web platform based entirely in Javascript that can be used to rapidly deploy scalable sites and site networks. With the advent of the Chrome JavaScript V8 runtime engine, Javascript can now be run server-side for deploying web applications. Because JavaScript uses event-driven and non-blocking I/O, Node.js is able to deliver high performance websites with the capability to handle a large amount of concurrent connections with a low resource impact.

This guide will cover two different methods for installing Node.js.

Install the Distro-Stable Version of Node.js with YUM

In order to download this version, we will use the yum package manager.

  1. Update your yum packages.
    sudo yum update
  2. Install Node.js.
    sudo yum install nodejs
  3. Verify the current version of Node.js:
    node --version
  4. Install npm (Node Package Manager)
    sudo yum install npm

Install Node.js using NVM

Instead of using yum, you can install Node.js with a tool called nvm, which stands for "Node.js Version Manager".

NVM lets you install multiple different versions of Node.js. This way, you have more control over your environment for whatever your project needs. NVM will also give you on-demand access to the latest versions of Node.js, and the ability to use previous releases that your application may be dependent on.

  1. Run yum update:
    sudo yum update
  2. Install tar:
    sudo yum install tar
  3. Download and install the installation script.

    Download the nvm installation script from the project's GitHub page:

    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

    This will download the script and execute it. It will install into a subdirectory of your home directory at ~/.nvm. It also adds the essential lines to your ~/.profile file to use the file with bash.

    This command will pull from the Github Master page so that it is always up to date, but you can use previous versions by finding the URL on that GitHub repository.

  4. Update your current session:
    source ~/.profile
  5. List available Node.js versions.

    Now that nvm is installed, you can install isolated Node.js versions:

    nvm ls-remote
    . . .
    v6.7.0
    v6.8.0
    v6.8.1
    v6.9.0
    v6.9.1
    v7.0.0
    v7.1.0
  6. Install the version of Node.js that you want to use.

    In this example, the newest version is v7.1.0. If you wanted to install V7.1.0 you can do so by using the nvm install command. If there is a newer version available, use that version.

    nvm install 7.1.0
  7. After the command runs, your desired version of Node.js will be installed.

Options

  • Typically, nvm will default to the newest version, but you can explicitly tell nvm to use a previous version by using the following syntax - where the highlighted portion is the version you wish to run:
    nvm use 7.0.0
  • When using nvm to install Node.js, the executable is simply called node. You can find out what Node.js version is being used by the shell by typing:
    node -v
  • This will display the version being used:
    v.7.1.0
  • If you have multiple versions of Node.js, you can determine the installed version by typing:
    nvm ls
  • To set a specific Node.js as default, you can use the following syntax where the highlighted portion of the text is the desired version:
    nvm alias default 7.1.0
  • That version will be automatically selected when a new session is generated. You can also reference it using an alias such as:
    nvm use default

    Each version of Node.js will keep track of its own packages and uses npm to manage them.

  • You can instruct npm to install different JavaScript packages to your Node.js project's ./node_modules. In this example, we will install Express.js:
    npm install express
  • If you want to make that package available globally to all your Node.js projects, you can simply add the -g flag:
    npm install -g express

    After that command has been run, the package will be installed in:

    ~/.nvm/node_version/lib/node_modules/package_name
  • Using the global installation will allow you to run the commands from the command line. However, you will have to link the package into your local sphere to require it from within an application. In this example, we are linking Express.js to our current project:
    npm link express
  • For any other information about the NVM command, you can use help:
    nvm help

Next Step

More Info


Was This Article Helpful?
Thank You For Your Feedback
Glad we helped! Anything more we can do for you?
Sorry about that. How can we be more helpful?