How to Install Node.js

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

Node.js is a cross-platform runtime environment for server-side JavaScript applications. Node.js uses V8, Google’s JavaScript engine, which is also found in Chromium and Chrome. Depending on the use case, Node.js can supplement or replace traditional web servers and tools such as Apache, nginx, or PHP.

Node.js can be installed and maintained multiple ways across the various platforms offered. Multiple releases of Node.js are available, along with multiple versions within the LTS branch. The decision about which of these versions to install can quickly become confusing, so this guide lists the main choices for installing Node.js on Linux, and some basic reasons why you may or may not want to use a certain method.

Package Manager

Linux Distro Repositories

Your distro’s repos likely contain an LTS release of Node.js. This is a good solution if:

  • You don’t need newer features.

  • You want the distro’s package manager to handle core updates.

  • You want to easily maintain uniformity among multiple Node.js servers.

NPM (Node Package Manager) is included with installations of Node.js by other methods. Here, however, npm is a separate package from nodejs and must be installed separately.

Note
Node.js from the distro’s repositories in Debian 7 or 8, or Ubuntu 12.04 or 14.04 conflict with the Amateur Packet Radio Node program. In this scenario, calling Node.js requires that you use the command nodejs -$option instead of the standard node -$option. One workaround is to install the package nodejs-legacy, which maintains a symlink from /usr/bin/node to /usr/bin/nodejs so the normal node commands can be used.

NodeSource Repository

The NodeSource repository is a continuation and expansion of Chris Lea’s Node.js Ubuntu PPA to offer both .deb and .rpm binaries for various Node.js release stages. This is the option mentioned on nodejs.org for those who would like to install using the operating system’s package manager. It generally provides more up-to-date packages than the distro’s repositories.

Node Version Manager

NVM is a separate project from Node.js and is one of the more common installation methods. NVM is installed using an installation script and its primary benefit is easy management of Node.js versions, including updating to newer releases and migrating your Node packages.

Official Binary Installer

Installers for all available platforms can be found at nodejs.org. A benefit of using the official installer is that GPG checksums are offered to verify the installer’s integrity.

Build from Source

Compiling from source code is the most advanced installation method, though it can be a remarkably simple process. Installing from source can add flexibility with compiling flags and ensures that you have the absolute latest codebase at the time of installation.

Node Package Manager (NPM)

A typical installation of Node.js includes the Node Package Manager (NPM). However, an exception is any Linux-distro-supplied version of Node.js which would need the package npm installed. NPM is a package manager for Node.js packages in the NPM repository. You can find extensive NPM documentation at npmjs.com.

Making a Quick Decision (the TL;DR)

Still not sure which installation method to use? Then NVM is probably your best choice to start with. NVM facilitates easy installation and maintenance of Node.js and NPM, presents no naming issues with other software, and easily manages multiple installations of Node.js that can test your application before you push a Node.js update into your production environment.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.