• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2title: npm-install-test
3section: 1
4description: Install package(s) and run tests
5---
6
7### Synopsis
8
9```bash
10npm install-test [<package-spec> ...]
11
12alias: it
13```
14
15### Description
16
17This command runs an `npm install` followed immediately by an `npm test`. It
18takes exactly the same arguments as `npm install`.
19
20### Configuration
21
22#### `save`
23
24* Default: `true` unless when using `npm update` where it defaults to `false`
25* Type: Boolean
26
27Save installed packages to a `package.json` file as dependencies.
28
29When used with the `npm rm` command, removes the dependency from
30`package.json`.
31
32Will also prevent writing to `package-lock.json` if set to `false`.
33
34
35
36#### `save-exact`
37
38* Default: false
39* Type: Boolean
40
41Dependencies saved to package.json will be configured with an exact version
42rather than using npm's default semver range operator.
43
44
45
46#### `global`
47
48* Default: false
49* Type: Boolean
50
51Operates in "global" mode, so that packages are installed into the `prefix`
52folder instead of the current working directory. See
53[folders](/configuring-npm/folders) for more on the differences in behavior.
54
55* packages are installed into the `{prefix}/lib/node_modules` folder, instead
56  of the current working directory.
57* bin files are linked to `{prefix}/bin`
58* man pages are linked to `{prefix}/share/man`
59
60
61
62#### `install-strategy`
63
64* Default: "hoisted"
65* Type: "hoisted", "nested", "shallow", or "linked"
66
67Sets the strategy for installing packages in node_modules. hoisted
68(default): Install non-duplicated in top-level, and duplicated as necessary
69within directory structure. nested: (formerly --legacy-bundling) install in
70place, no hoisting. shallow (formerly --global-style) only install direct
71deps at top-level. linked: (experimental) install in node_modules/.store,
72link in place, unhoisted.
73
74
75
76#### `legacy-bundling`
77
78* Default: false
79* Type: Boolean
80* DEPRECATED: This option has been deprecated in favor of
81  `--install-strategy=nested`
82
83Instead of hoisting package installs in `node_modules`, install packages in
84the same manner that they are depended on. This may cause very deep
85directory structures and duplicate package installs as there is no
86de-duplicating. Sets `--install-strategy=nested`.
87
88
89
90#### `global-style`
91
92* Default: false
93* Type: Boolean
94* DEPRECATED: This option has been deprecated in favor of
95  `--install-strategy=shallow`
96
97Only install direct dependencies in the top level `node_modules`, but hoist
98on deeper dependencies. Sets `--install-strategy=shallow`.
99
100
101
102#### `omit`
103
104* Default: 'dev' if the `NODE_ENV` environment variable is set to
105  'production', otherwise empty.
106* Type: "dev", "optional", or "peer" (can be set multiple times)
107
108Dependency types to omit from the installation tree on disk.
109
110Note that these dependencies _are_ still resolved and added to the
111`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
112physically installed on disk.
113
114If a package type appears in both the `--include` and `--omit` lists, then
115it will be included.
116
117If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
118variable will be set to `'production'` for all lifecycle scripts.
119
120
121
122#### `include`
123
124* Default:
125* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
126
127Option that allows for defining which types of dependencies to install.
128
129This is the inverse of `--omit=<type>`.
130
131Dependency types specified in `--include` will not be omitted, regardless of
132the order in which omit/include are specified on the command-line.
133
134
135
136#### `strict-peer-deps`
137
138* Default: false
139* Type: Boolean
140
141If set to `true`, and `--legacy-peer-deps` is not set, then _any_
142conflicting `peerDependencies` will be treated as an install failure, even
143if npm could reasonably guess the appropriate resolution based on non-peer
144dependency relationships.
145
146By default, conflicting `peerDependencies` deep in the dependency graph will
147be resolved using the nearest non-peer dependency specification, even if
148doing so will result in some packages receiving a peer dependency outside
149the range set in their package's `peerDependencies` object.
150
151When such an override is performed, a warning is printed, explaining the
152conflict and the packages involved. If `--strict-peer-deps` is set, then
153this warning is treated as a failure.
154
155
156
157#### `prefer-dedupe`
158
159* Default: false
160* Type: Boolean
161
162Prefer to deduplicate packages if possible, rather than choosing a newer
163version of a dependency.
164
165
166
167#### `package-lock`
168
169* Default: true
170* Type: Boolean
171
172If set to false, then ignore `package-lock.json` files when installing. This
173will also prevent _writing_ `package-lock.json` if `save` is true.
174
175
176
177#### `package-lock-only`
178
179* Default: false
180* Type: Boolean
181
182If set to true, the current operation will only use the `package-lock.json`,
183ignoring `node_modules`.
184
185For `update` this means only the `package-lock.json` will be updated,
186instead of checking `node_modules` and downloading dependencies.
187
188For `list` this means the output will be based on the tree described by the
189`package-lock.json`, rather than the contents of `node_modules`.
190
191
192
193#### `foreground-scripts`
194
195* Default: `false` unless when using `npm pack` or `npm publish` where it
196  defaults to `true`
197* Type: Boolean
198
199Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
200scripts for installed packages in the foreground process, sharing standard
201input, output, and error with the main npm process.
202
203Note that this will generally make installs run slower, and be much noisier,
204but can be useful for debugging.
205
206
207
208#### `ignore-scripts`
209
210* Default: false
211* Type: Boolean
212
213If true, npm does not run scripts specified in package.json files.
214
215Note that commands explicitly intended to run a particular script, such as
216`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script`
217will still run their intended script if `ignore-scripts` is set, but they
218will *not* run any pre- or post-scripts.
219
220
221
222#### `audit`
223
224* Default: true
225* Type: Boolean
226
227When "true" submit audit reports alongside the current npm command to the
228default registry and all registries configured for scopes. See the
229documentation for [`npm audit`](/commands/npm-audit) for details on what is
230submitted.
231
232
233
234#### `bin-links`
235
236* Default: true
237* Type: Boolean
238
239Tells npm to create symlinks (or `.cmd` shims on Windows) for package
240executables.
241
242Set to false to have it not do this. This can be used to work around the
243fact that some file systems don't support symlinks, even on ostensibly Unix
244systems.
245
246
247
248#### `fund`
249
250* Default: true
251* Type: Boolean
252
253When "true" displays the message at the end of each `npm install`
254acknowledging the number of dependencies looking for funding. See [`npm
255fund`](/commands/npm-fund) for details.
256
257
258
259#### `dry-run`
260
261* Default: false
262* Type: Boolean
263
264Indicates that you don't want npm to make any changes and that it should
265only report what it would have done. This can be passed into any of the
266commands that modify your local installation, eg, `install`, `update`,
267`dedupe`, `uninstall`, as well as `pack` and `publish`.
268
269Note: This is NOT honored by other network related commands, eg `dist-tags`,
270`owner`, etc.
271
272
273
274#### `cpu`
275
276* Default: null
277* Type: null or String
278
279Override CPU architecture of native modules to install. Acceptable values
280are same as `cpu` field of package.json, which comes from `process.arch`.
281
282
283
284#### `os`
285
286* Default: null
287* Type: null or String
288
289Override OS of native modules to install. Acceptable values are same as `os`
290field of package.json, which comes from `process.platform`.
291
292
293
294#### `libc`
295
296* Default: null
297* Type: null or String
298
299Override libc of native modules to install. Acceptable values are same as
300`libc` field of package.json
301
302
303
304#### `workspace`
305
306* Default:
307* Type: String (can be set multiple times)
308
309Enable running a command in the context of the configured workspaces of the
310current project while filtering by running only the workspaces defined by
311this configuration option.
312
313Valid values for the `workspace` config are either:
314
315* Workspace names
316* Path to a workspace directory
317* Path to a parent workspace directory (will result in selecting all
318  workspaces within that folder)
319
320When set for the `npm init` command, this may be set to the folder of a
321workspace which does not yet exist, to create the folder and set it up as a
322brand new workspace within the project.
323
324This value is not exported to the environment for child processes.
325
326#### `workspaces`
327
328* Default: null
329* Type: null or Boolean
330
331Set to true to run the command in the context of **all** configured
332workspaces.
333
334Explicitly setting this to false will cause commands like `install` to
335ignore workspaces altogether. When not set explicitly:
336
337- Commands that operate on the `node_modules` tree (install, update, etc.)
338will link workspaces into the `node_modules` folder. - Commands that do
339other things (test, exec, publish, etc.) will operate on the root project,
340_unless_ one or more workspaces are specified in the `workspace` config.
341
342This value is not exported to the environment for child processes.
343
344#### `include-workspace-root`
345
346* Default: false
347* Type: Boolean
348
349Include the workspace root when workspaces are enabled for a command.
350
351When false, specifying individual workspaces via the `workspace` config, or
352all workspaces via the `workspaces` flag, will cause npm to operate only on
353the specified workspaces, and not on the root project.
354
355This value is not exported to the environment for child processes.
356
357#### `install-links`
358
359* Default: false
360* Type: Boolean
361
362When set file: protocol dependencies will be packed and installed as regular
363dependencies instead of creating a symlink. This option has no effect on
364workspaces.
365
366
367
368### See Also
369
370* [npm install](/commands/npm-install)
371* [npm install-ci-test](/commands/npm-install-ci-test)
372* [npm test](/commands/npm-test)
373