• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2section: cli-commands
3title: npm-prune
4description: Remove extraneous packages
5---
6
7# npm-prune(1)
8## Remove extraneous packages
9
10### Synopsis
11
12```bash
13npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]
14```
15
16### Description
17
18This command removes "extraneous" packages.  If a package name is
19provided, then only packages matching one of the supplied names are
20removed.
21
22Extraneous packages are packages that are not listed on the parent
23package's dependencies list.
24
25If the `--production` flag is specified or the `NODE_ENV` environment
26variable is set to `production`, this command will remove the packages
27specified in your `devDependencies`. Setting `--no-production` will
28negate `NODE_ENV` being set to `production`.
29
30If the `--dry-run` flag is used then no changes will actually be made.
31
32If the `--json` flag is used then the changes `npm prune` made (or would
33have made with `--dry-run`) are printed as a JSON object.
34
35In normal operation with package-locks enabled, extraneous modules are
36pruned automatically when modules are installed and you'll only need
37this command with the `--production` flag.
38
39If you've disabled package-locks then extraneous modules will not be removed
40and it's up to you to run `npm prune` from time-to-time to remove them.
41
42### See Also
43
44* [npm uninstall](/cli-commands/npm-uninstall)
45* [npm folders](/configuring-npm/folders)
46* [npm ls](/cli-commands/npm-ls)
47