1NPM-PRUNE(1)                                                      NPM-PRUNE(1)
2
3
4

NAME

6       npm-prune - Remove extraneous packages
7
8   Synopsis
9         npm prune [[<@scope>/]<pkg>...]
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   omit
36       •   Default: 'dev' if the NODE_ENV environment variable is set to 'pro‐
37           duction', otherwise empty.
38
39       •   Type: "dev", "optional", or "peer" (can be set multiple times)
40
41
42       Dependency types to omit from the installation tree on disk.
43
44       Note that these dependencies are still resolved and added to the  pack‐
45       age-lock.json or npm-shrinkwrap.json file. They are just not physically
46       installed on disk.
47
48       If a package type appears in both the --include and --omit lists,  then
49       it will be included.
50
51       If  the  resulting omit list includes 'dev', then the NODE_ENV environ‐
52       ment variable will be set to 'production' for all lifecycle scripts.
53
54   include
55       •   Default:
56
57       •   Type: "prod", "dev", "optional", or "peer"  (can  be  set  multiple
58           times)
59
60
61       Option that allows for defining which types of dependencies to install.
62
63       This is the inverse of --omit=<type>.
64
65       Dependency types specified in --include will not be omitted, regardless
66       of the order in which omit/include are specified on the command-line.
67
68   dry-run
69       •   Default: false
70
71       •   Type: Boolean
72
73
74       Indicates that you don't want npm to  make  any  changes  and  that  it
75       should only report what it would have done. This can be passed into any
76       of the commands that modify your local installation, eg,  install,  up‐
77       date, dedupe, uninstall, as well as pack and publish.
78
79       Note:  This  is NOT honored by other network related commands, eg dist-
80       tags, owner, etc.
81
82   json
83       •   Default: false
84
85       •   Type: Boolean
86
87
88       Whether or not to output JSON data, rather than the normal output.
89
90       •   In npm pkg set it enables parsing set values with JSON.parse()  be‐
91           fore saving them to your package.json.
92
93
94       Not supported by all npm commands.
95
96   foreground-scripts
97       •   Default: false
98
99       •   Type: Boolean
100
101
102       Run  all  build  scripts  (ie,  preinstall,  install,  and postinstall)
103       scripts for installed packages in the foreground process, sharing stan‐
104       dard input, output, and error with the main npm process.
105
106       Note  that  this  will  generally make installs run slower, and be much
107       noisier, but can be useful for debugging.
108
109   ignore-scripts
110       •   Default: false
111
112       •   Type: Boolean
113
114
115       If true, npm does not run scripts specified in package.json files.
116
117       Note that commands explicitly intended to run a particular script, such
118       as  npm start, npm stop, npm restart, npm test, and npm run-script will
119       still run their intended script if ignore-scripts is set, but they will
120       not run any pre- or post-scripts.
121
122   workspace
123       •   Default:
124
125       •   Type: String (can be set multiple times)
126
127
128       Enable running a command in the context of the configured workspaces of
129       the current project while filtering by running only the workspaces  de‐
130       fined by this configuration option.
131
132       Valid values for the workspace config are either:
133
134       •   Workspace names
135
136       •   Path to a workspace directory
137
138       •   Path  to a parent workspace directory (will result in selecting all
139           workspaces within that folder)
140
141
142       When set for the npm init command, this may be set to the folder  of  a
143       workspace  which does not yet exist, to create the folder and set it up
144       as a brand new workspace within the project.
145
146       This value is not exported to the environment for child processes.
147
148   workspaces
149       •   Default: null
150
151       •   Type: null or Boolean
152
153
154       Set to true to run  the  command  in  the  context  of  all  configured
155       workspaces.
156
157       Explicitly  setting  this  to false will cause commands like install to
158       ignore workspaces altogether. When not set explicitly:
159
160       •   Commands that operate on the node_modules  tree  (install,  update,
161           etc.) will link workspaces into the node_modules folder. - Commands
162           that do other things (test, exec, publish, etc.)  will  operate  on
163           the  root  project,  unless one or more workspaces are specified in
164           the workspace config.
165
166
167       This value is not exported to the environment for child processes.
168
169   include-workspace-root
170       •   Default: false
171
172       •   Type: Boolean
173
174
175       Include the workspace root when workspaces are enabled for a command.
176
177       When false, specifying individual workspaces via the workspace  config,
178       or  all  workspaces  via the workspaces flag, will cause npm to operate
179       only on the specified workspaces, and not on the root project.
180
181       This value is not exported to the environment for child processes.
182
183   install-links
184       •   Default: false
185
186       •   Type: Boolean
187
188
189       When set file: protocol dependencies will be packed  and  installed  as
190       regular  dependencies instead of creating a symlink. This option has no
191       effect on workspaces.
192
193   See Also
194       •   npm help uninstall
195
196       •   npm help folders
197
198       •   npm help ls
199
200
201
202                                 November 2023                    NPM-PRUNE(1)
Impressum