2019-11-05 14:55:08 -05:00
|
|
|
---
|
2019-11-18 21:01:39 +02:00
|
|
|
section: cli-commands
|
2019-11-05 14:55:08 -05:00
|
|
|
title: npm-prune
|
|
|
|
description: Remove extraneous packages
|
|
|
|
---
|
2011-11-21 09:48:45 -08:00
|
|
|
|
2019-11-18 21:01:39 +02:00
|
|
|
# npm-prune(1)
|
2019-11-05 14:55:08 -05:00
|
|
|
## Remove extraneous packages
|
2011-11-21 09:48:45 -08:00
|
|
|
|
2019-11-05 14:55:08 -05:00
|
|
|
### Synopsis
|
2011-11-21 09:48:45 -08:00
|
|
|
|
2019-11-05 14:55:08 -05:00
|
|
|
```bash
|
|
|
|
npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]
|
|
|
|
```
|
|
|
|
|
|
|
|
### Description
|
2011-11-21 09:48:45 -08:00
|
|
|
|
|
|
|
This command removes "extraneous" packages. If a package name is
|
|
|
|
provided, then only packages matching one of the supplied names are
|
|
|
|
removed.
|
|
|
|
|
|
|
|
Extraneous packages are packages that are not listed on the parent
|
|
|
|
package's dependencies list.
|
|
|
|
|
2015-06-12 04:04:17 -04:00
|
|
|
If the `--production` flag is specified or the `NODE_ENV` environment
|
|
|
|
variable is set to `production`, this command will remove the packages
|
2018-04-20 18:26:37 -07:00
|
|
|
specified in your `devDependencies`. Setting `--no-production` will
|
2015-06-12 04:04:17 -04:00
|
|
|
negate `NODE_ENV` being set to `production`.
|
2013-10-24 09:21:59 -07:00
|
|
|
|
2018-04-20 18:26:37 -07:00
|
|
|
If the `--dry-run` flag is used then no changes will actually be made.
|
|
|
|
|
|
|
|
If the `--json` flag is used then the changes `npm prune` made (or would
|
|
|
|
have made with `--dry-run`) are printed as a JSON object.
|
|
|
|
|
|
|
|
In normal operation with package-locks enabled, extraneous modules are
|
|
|
|
pruned automatically when modules are installed and you'll only need
|
|
|
|
this command with the `--production` flag.
|
|
|
|
|
|
|
|
If you've disabled package-locks then extraneous modules will not be removed
|
|
|
|
and it's up to you to run `npm prune` from time-to-time to remove them.
|
|
|
|
|
2019-11-05 14:55:08 -05:00
|
|
|
### See Also
|
2011-11-21 09:48:45 -08:00
|
|
|
|
2020-10-02 17:52:19 -04:00
|
|
|
* [npm uninstall](/cli-commands/uninstall)
|
2019-11-05 14:55:08 -05:00
|
|
|
* [npm folders](/configuring-npm/folders)
|
2020-10-02 17:52:19 -04:00
|
|
|
* [npm ls](/cli-commands/ls)
|