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 in selecting all
110 workspaces within that folder)
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: null
124
125 • Type: null or Boolean
126
127
128 Set to true to run the command in the context of all configured
129 workspaces.
130
131 Explicitly setting this to false will cause commands like install to
132 ignore workspaces altogether. When not set explicitly:
133
134 • Commands that operate on the node_modules tree (install, update,
135 etc.) will link workspaces into the node_modules folder. - Commands
136 that do other things (test, exec, publish, etc.) will operate on the
137 root project, unless one or more workspaces are specified in the
138 workspace config.
139
140
141 This value is not exported to the environment for child processes.
142 <!-- automatically generated, do not edit manually --> <!-- see
143 lib/utils/config/definitions.js -->
144
145
146 include-workspace-root
147 • Default: false
148
149 • Type: Boolean
150
151
152 Include the workspace root when workspaces are enabled for a command.
153
154 When false, specifying individual workspaces via the workspace config,
155 or all workspaces via the workspaces flag, will cause npm to operate
156 only on the specified workspaces, and not on the root project. <!--
157 automatically generated, do not edit manually --> <!-- see
158 lib/utils/config/definitions.js -->
159
160 <!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
161
162
163 See Also
164 • npm help uninstall
165
166 • npm help folders
167
168 • npm help ls
169
170
171
172
173 January 2022 NPM-PRUNE(1)