# Uninstalling npm packages with npm uninstall

> Learn how to uninstall an npm package with npm uninstall, removing it from package.json, plus the -D flag for dev dependencies and -g for global packages.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-08-16 | Updated: 2022-02-09 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/npm-uninstall-packages/

To uninstall a package you have previously installed **locally** (using `npm install <package-name>` in the `node_modules` folder, run

```bash
npm uninstall <package-name>
```

from the project root folder (the folder that contains the node_modules folder).

This operation will also remove the reference in the [`package.json` file](https://flaviocopes.com/package-json/).

If the package was a development dependency, listed in the devDependencies of the `package.json` file, you must use the `-D` / `--save-dev` flag to remove it from the file:

```bash
npm uninstall -D <package-name>
```

If the package is installed **globally**, you need to add the `-g` / `--global` flag:

```bash
npm uninstall -g <package-name>
```

for example:

```bash
npm uninstall -g webpack
```

and you can run this command from anywhere you want on your system because the folder where you currently are does not matter.
