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