Difference between NPM and NVM

node.jsNpmNvm

node.js Problem Overview


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?

node.js Solutions


Solution 1 - node.js

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 you want to keep multiple versions of Node.js installed on your system or if you'd like to upgrade your current version.

Solution 2 - node.js

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.

Solution 3 - node.js

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).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohnTheBelovedView Question on Stackoverflow
Solution 1 - node.jsThomasReggiView Answer on Stackoverflow
Solution 2 - node.jsmasimploView Answer on Stackoverflow
Solution 3 - node.jsazizbroView Answer on Stackoverflow