1 ---
2 title: npm-prune
3 section: 1
4 description: Remove extraneous packages
5 github_repo: npm/cli
6 github_branch: release/v6
7 github_path: docs/content/commands/npm-prune.md
8 redirect_from:
9 - /cli-documentation/v6/cli-commands/npm-prune
10 - /cli-documentation/v6/cli-commands/prune
11 - /cli-documentation/v6/commands/npm-prune
12 - /cli-documentation/v6/commands/prune
13 - /cli-documentation/v6/npm-prune
14 - /cli-documentation/v6/prune
15 - /cli/v6/cli-commands/npm-prune
16 - /cli/v6/cli-commands/prune
17 - /cli/v6/commands/prune
18 - /cli/v6/npm-prune
19 - /cli/v6/prune
20 ---
21
22 ### Synopsis
23
24 ```bash
25 npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]
26 ```
27
28 ### Description
29
30 This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed.
31
32 Extraneous packages are packages that are not listed on the parent package's dependencies list.
33
34 If the `--production` flag is specified or the `NODE_ENV` environment variable is set to `production`, this command will remove the packages specified in your `devDependencies`. Setting `--no-production` will negate `NODE_ENV` being set to `production`.
35
36 If the `--dry-run` flag is used then no changes will actually be made.
37
38 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.
39
40 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.
41
42 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.
43
44 ### See Also
45
46 - [npm uninstall](/cli/v6/commands/npm-uninstall)
47 - [npm folders](/cli/v6/configuring-npm/folders)
48 - [npm ls](/cli/v6/commands/npm-ls)