%%
date:: [[2022-09-01]], [[2022-12-23]]
%%
# [[Node Package Manager]]
NPM is a [[Package Manager]] for [[NodeJS]]. It is a way to install modules that have been published without needing to know their location. NPM also allows the installation of multiple packages that a project requires with one command.
For example, `npm install -g gatsby-cli` installs [[Gatsby]] and all modules it requires.
NPM gets the list of packages from `package.json`, which should be included in Node.js projects.
## Installing NPM itself
[Here are the docs](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) for installing NPM on various operating systems.
You can install NPM as part of [[NodeJS]], which means you can also install it using [[Node Version Manager|NVM]].
### Installing the latest version of NPM
If you already have NPM, you can use it to install the latest version of itself with:
```
npm install -g npm
```
### Checking NPM version
```
npm -v
```
## Installing NPM packages
### `npm install` vs `npm update`
Both commands update local dependencies as specified by the project.
The main difference is that `npm install` will not update a module that is already installed *and* has fuzzy versioning, while `npm update` does. [^stackoverflow]
## Uninstalling NPM packages
```bash
npm uninstall package1 package2
```
[^stackoverflow]: Kurdziel, S. (2018). *NPM install vs update what's the difference*. Retrieved from [Stack Overflow](https://stackoverflow.com/questions/12478679/npm-install-vs-update-whats-the-difference).