139

I know npm is the package manager and nvm is the node version manager. I am currently trying to auto-install my development and production environment using Bash and forgot how I started out and in what order. After installing npm, I found our nvm was not installed.

Do I still need to install nvm? If so, what is the benefit?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
JohnTheBeloved
  • 2,323
  • 3
  • 19
  • 24
  • 10
    nvm installs Node which installs npm. If you don't need/want to switch between Node versions then you don't probably don't need nvm. – Felix Kling Sep 18 '15 at 21:05

3 Answers3

157

nvm (Node Version Manager) is a tool that allows you to download and install Node.js. Check if you have it installed via nvm --version.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash

npm (Node Package Manager) is a tool that allows you to install javascript packages. Check if you have it installed via npm --version.

npm comes with Node.js so if you have node installed (node --version) you most likely have npm installed as well.

You don't need nvm unless you want to keep multiple versions of Node.js installed on your system or if you'd like to upgrade your version.

Pang
  • 9,564
  • 146
  • 81
  • 122
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
  • 1
    which means that i can use `nvm install watchman` instead of `npm install watchman` because i don't want to change npm versions – AVI Feb 05 '17 at 05:06
  • @JokerFan That's not exactly true. You can not run `nvm install watchman`. When you change your version of `node` with `nvm` the version of `npm` changes as well. – ThomasReggi Feb 06 '17 at 02:01
  • 3
    Does it makes sense to have multiple version of Node.js on system ? – Ajay S Apr 18 '17 at 04:49
  • 3
    @AjayS You may work on two separate projects that have very specific node version requirements, very common for contractors. – Ruan Mendes Jun 26 '18 at 14:02
34

nvm as you said is an "active" nodejs version manager. You can have multiple versions of node on the same machine and switch by doing "nvm use version". npm respects nvm if it is present on the machine, meaning if you have 0.12.7 active and do npm install -g uuid, it will install it globally under 0.12.7 but if you switch to 4.0.0, uuid will no longer be globally available.

In any case you do not necessarily need nvm to install packages.

masimplo
  • 3,674
  • 2
  • 30
  • 47
16

I see an analogy with Python for all the Python users out there.

nvm manages different versions of node. And node contains npm (package manager).

pyenv manages different versions of python. And python contains pip (package manager).

azizbro
  • 3,069
  • 4
  • 22
  • 36