1NPM-PRUNE(1) NPM-PRUNE(1)
2
3
4
6 npm-prune - Remove extraneous packages
7
8 Synopsis
9 npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]
10
11 Description
12 This command removes "extraneous" packages. If a package name is pro‐
13 vided, then only packages matching one of the supplied names are re‐
14 moved.
15
16 Extraneous packages are those present in the node_modules folder that
17 are not listed as any package's dependency list.
18
19 If the --production flag is specified or the NODE_ENV environment vari‐
20 able is set to production, this command will remove the packages speci‐
21 fied in your devDependencies. Setting --no-production will negate
22 NODE_ENV being set to production.
23
24 If the --dry-run flag is used then no changes will actually be made.
25
26 If the --json flag is used, then the changes npm prune made (or would
27 have made with --dry-run) are printed as a JSON object.
28
29 In normal operation, extraneous modules are pruned automatically, so
30 you'll only need this command with the --production flag. However, in
31 the real world, operation is not always "normal". When crashes or mis‐
32 takes happen, this command can help clean up any resulting garbage.
33
34 Configuration
35 <!-- AUTOGENERATED CONFIG DESCRIPTIONS START --> <!-- automatically
36 generated, do not edit manually --> <!-- see lib/utils/config/defini‐
37 tions.js -->
38
39 omit
40 • Default: 'dev' if the NODE_ENV environment variable is set to 'pro‐
41 duction', otherwise empty.
42
43 • Type: "dev", "optional", or "peer" (can be set multiple times)
44
45
46 Dependency types to omit from the installation tree on disk.
47
48 Note that these dependencies are still resolved and added to the pack‐
49 age-lock.json or npm-shrinkwrap.json file. They are just not physically
50 installed on disk.
51
52 If a package type appears in both the --include and --omit lists, then
53 it will be included.
54
55 If the resulting omit list includes 'dev', then the NODE_ENV environ‐
56 ment variable will be set to 'production' for all lifecycle scripts.
57 <!-- automatically generated, do not edit manually --> <!-- see
58 lib/utils/config/definitions.js -->
59
60
61 dry-run
62 • Default: false
63
64 • Type: Boolean
65
66
67 Indicates that you don't want npm to make any changes and that it
68 should only report what it would have done. This can be passed into any
69 of the commands that modify your local installation, eg, install, up‐
70 date, dedupe, uninstall, as well as pack and publish.
71
72 Note: This is NOT honored by other network related commands, eg
73 dist-tags, owner, etc. <!-- automatically generated, do not edit manu‐
74 ally --> <!-- see lib/utils/config/definitions.js -->
75
76
77 json
78 • Default: false
79
80 • Type: Boolean
81
82
83 Whether or not to output JSON data, rather than the normal output.
84
85 • In npm pkg set it enables parsing set values with JSON.parse() before
86 saving them to your package.json.
87
88
89 Not supported by all npm commands. <!-- automatically generated, do
90 not edit manually --> <!-- see lib/utils/config/definitions.js -->
91
92
93 workspace
94 • Default:
95
96 • Type: String (can be set multiple times)
97
98
99 Enable running a command in the context of the configured workspaces of
100 the current project while filtering by running only the workspaces de‐
101 fined by this configuration option.
102
103 Valid values for the workspace config are either:
104
105 • Workspace names
106
107 • Path to a workspace directory
108
109 • Path to a parent workspace directory (will result to selecting all of
110 the nested workspaces)
111
112
113 When set for the npm init command, this may be set to the folder of a
114 workspace which does not yet exist, to create the folder and set it up
115 as a brand new workspace within the project.
116
117 This value is not exported to the environment for child processes.
118 <!-- automatically generated, do not edit manually --> <!-- see
119 lib/utils/config/definitions.js -->
120
121
122 workspaces
123 • Default: false
124
125 • Type: Boolean
126
127
128 Enable running a command in the context of all the configured
129 workspaces.
130
131 This value is not exported to the environment for child processes.
132 <!-- automatically generated, do not edit manually --> <!-- see
133 lib/utils/config/definitions.js -->
134
135 <!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
136
137
138 See Also
139 • npm help uninstall
140
141 • npm help folders
142
143 • npm help ls
144
145
146
147
148 October 2021 NPM-PRUNE(1)