DEV Community

Cover image for Install NVM (Node Version Manager) and Node.js
Batkhuu
Batkhuu

Posted on Edited on

Install NVM (Node Version Manager) and Node.js

NVM (Node Version Manager)

NVM is a tool for managing multiple versions of Node.js.

Features

  • Cross-platform
  • Node.js
  • Manager for multiple versions of Node.js, npm, and yarn
  • Multiple Node.js environments

Official pages


Install on Linux or macOS

1. Download and install NVM (v0.39.1)

## Recommended path to install NVM:
# Set and export `NVM_DIR` environment variable. For example:
mkdir -vp ~/workspaces/runtimes/.nvm
export NVM_DIR="${HOME}/workspaces/runtimes/.nvm"

# Install NVM:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash


## For bash:
# Load .bashrc file to init NVM into current bash session:
source ~/.bashrc

## For zsh:
# Load .zshrc file to init NVM into current zsh session:
source ~/.zshrc


# Check installed NVM version:
nvm --version
Enter fullscreen mode Exit fullscreen mode

2. Install Node.js

# Install Node.js, update NPM to latest, and set default Node.js:
nvm install --latest-npm --alias=default 16.14.2
# Set to use default Node.js:
nvm use default

# Clean NVM caches:
nvm cache clear

# Check installed Node.js and NPM version:
node -v
npm -v

# Install essential extra packages:
npm install -g pm2 newman jshint
pm2 install pm2-logrotate

# Clean NPM caches:
npm cache clean --force
Enter fullscreen mode Exit fullscreen mode

👍 ✨

INSTALLATION COMPLETE (Linux, macOS)


Install on Windows

1. Download and install NVM-Windows (v1.1.9)

2. Install Node.js (Windows)

nvm install 16.14.2
nvm use 16.14.2
Enter fullscreen mode Exit fullscreen mode

👍 ✨

INSTALLATION COMPLETE (Windows)


Usage

# NVM help:
nvm -h
Enter fullscreen mode Exit fullscreen mode

References

Top comments (0)