Knowledge Base

Install Node.JS via Node Version Manager on Ubuntu 14.04

  • Last Created On Dec 06, 2024
  • 24
0 0

Easily install and manage any version of Node.JS using the Node Version Manager (NVM). NVM is similar to Ruby’s RVM, allowing you to install and switch between different versions of Node.JS and NPM using the command line.

Update Ubuntu

Make sure to update your Ubuntu box with the latest packages by running these commands:

apt-get && apt-get upgrade

Install NVM

Install NVM by running this command:

curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash

This will download the latest install script for NVM via curl and execute it. This usually only takes a few seconds. Once NVM has downloaded and finished installing, it will ask you to close and reopen your terminal. This will not be necessary, simply run:

source /root/.bashrc

Ensure NVM is properly installed by running the following command. This will output the usage instructions for NVM.

nvm

Install latest Node.JS

At the writing of this article, the latest major version of Node.JS is version 0.12.x. We will be using this version as an example. Install version 0.12.

nvm install 0.12

You can replace 0.12 with any version of node that’s available (0.10, 0.11.2, etc). NVM will download a pre-built binary version of Node.JS and install it. This should only take a few seconds. Once installation has completed, NVM will output the version installed, such as:

Now using node v0.12.0

Test your node installation. This command will output the version of node that has been installed.

node -v

Set default version

To ensure that the same node version is used the next time you log in via ssh, you can set a “default” node version by running:

nvm alias default 0.12

This will ensure that version 0.12 of node is always used when logging onto the server.

Switching Between Versions

Using NVM, you can install multiple versions of node. Once a different version is installed, for example 0.10, you can switch to that node version by running:

nvm use 0.10

Note that when switching between node versions, the associated npm version and any global npm packages will be changed as well. You may need to reinstall your global npm packages when switching to a recently installed version.

Views: 24

Recent Articles

  • How to Install JAX with ROCm Acceleratio...
    89
  • Deploy a PyTorch Workspace on a Vultr Cl...
    70
  • Managing Backup Storage
    80
  • Automating FTP Backups in Windows Server
    70
  • Automating FTP Backups in Linux
    74

Popular Articles

  • Our General Terms & Conditions
    2595
  • Our Privacy Policy
    2445
  • Our Cookies Policy
    270
  • Our Terms of Use
    149
  • How to Install JAX with ROCm Acceleratio...
    89