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: release/v9
7 github_path: docs/lib/content/commands/npm-install-test.md
8 redirect_from:
9 - /cli-documentation/v9/cli-commands/install-test
10 - /cli-documentation/v9/cli-commands/npm-install-test
11 - /cli-documentation/v9/commands/install-test
12 - /cli-documentation/v9/commands/npm-install-test
13 - /cli-documentation/v9/install-test
14 - /cli-documentation/v9/npm-install-test
15 - /cli/v9/cli-commands/install-test
16 - /cli/v9/cli-commands/npm-install-test
17 - /cli/v9/commands/install-test
18 - /cli/v9/install-test
19 - /cli/v9/npm-install-test
20 ---
21
22 ### Synopsis
23
24 ```bash
25 npm install-test [<package-spec> ...]
26
27 alias: it
28 ```
29
30 ### Description
31
32 This command runs an `npm install` followed immediately by an `npm test`. It takes exactly the same arguments as `npm install`.
33
34 ### Configuration
35
36 #### `save`
37
38 - Default: `true` unless when using `npm update` where it defaults to `false`
39 - Type: Boolean
40
41 Save installed packages to a `package.json` file as dependencies.
42
43 When used with the `npm rm` command, removes the dependency from `package.json`.
44
45 Will also prevent writing to `package-lock.json` if set to `false`.
46
47 #### `save-exact`
48
49 - Default: false
50 - Type: Boolean
51
52 Dependencies saved to package.json will be configured with an exact version rather than using npm's default semver range operator.
53
54 #### `global`
55
56 - Default: false
57 - Type: Boolean
58
59 Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See [folders](/cli/v9/configuring-npm/folders) for more on the differences in behavior.
60
61 - packages are installed into the `{prefix}/lib/node_modules` folder, instead of the current working directory.
62 - bin files are linked to `{prefix}/bin`
63 - man pages are linked to `{prefix}/share/man`
64
65 #### `install-strategy`
66
67 - Default: "hoisted"
68 - Type: "hoisted", "nested", "shallow", or "linked"
69
70 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.
71
72 #### `legacy-bundling`
73
74 - Default: false
75 - Type: Boolean
76 - DEPRECATED: This option has been deprecated in favor of `--install-strategy=nested`
77
78 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`.
79
80 #### `global-style`
81
82 - Default: false
83 - Type: Boolean
84 - DEPRECATED: This option has been deprecated in favor of `--install-strategy=shallow`
85
86 Only install direct dependencies in the top level `node_modules`, but hoist on deeper dependencies. Sets `--install-strategy=shallow`.
87
88 #### `omit`
89
90 - Default: 'dev' if the `NODE_ENV` environment variable is set to 'production', otherwise empty.
91 - Type: "dev", "optional", or "peer" (can be set multiple times)
92
93 Dependency types to omit from the installation tree on disk.
94
95 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.
96
97 If a package type appears in both the `--include` and `--omit` lists, then it will be included.
98
99 If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment variable will be set to `'production'` for all lifecycle scripts.
100
101 #### `strict-peer-deps`
102
103 - Default: false
104 - Type: Boolean
105
106 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.
107
108 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.
109
110 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.
111
112 #### `prefer-dedupe`
113
114 - Default: false
115 - Type: Boolean
116
117 Prefer to deduplicate packages if possible, rather than choosing a newer version of a dependency.
118
119 #### `package-lock`
120
121 - Default: true
122 - Type: Boolean
123
124 If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true.
125
126 #### `package-lock-only`
127
128 - Default: false
129 - Type: Boolean
130
131 If set to true, the current operation will only use the `package-lock.json`, ignoring `node_modules`.
132
133 For `update` this means only the `package-lock.json` will be updated, instead of checking `node_modules` and downloading dependencies.
134
135 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`.
136
137 #### `foreground-scripts`
138
139 - Default: false
140 - Type: Boolean
141
142 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.
143
144 Note that this will generally make installs run slower, and be much noisier, but can be useful for debugging.
145
146 #### `ignore-scripts`
147
148 - Default: false
149 - Type: Boolean
150
151 If true, npm does not run scripts specified in package.json files.
152
153 Note that commands explicitly intended to run a particular script, such as `npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script` will still run their intended script if `ignore-scripts` is set, but they will _not_ run any pre- or post-scripts.
154
155 #### `audit`
156
157 - Default: true
158 - Type: Boolean
159
160 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/v9/commands/npm-audit) for details on what is submitted.
161
162 #### `bin-links`
163
164 - Default: true
165 - Type: Boolean
166
167 Tells npm to create symlinks (or `.cmd` shims on Windows) for package executables.
168
169 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.
170
171 #### `fund`
172
173 - Default: true
174 - Type: Boolean
175
176 When "true" displays the message at the end of each `npm install` acknowledging the number of dependencies looking for funding. See [`npm fund`](/cli/v9/commands/npm-fund) for details.
177
178 #### `dry-run`
179
180 - Default: false
181 - Type: Boolean
182
183 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`.
184
185 Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc.
186
187 #### `cpu`
188
189 - Default: null
190 - Type: null or String
191
192 Override CPU architecture of native modules to install. Acceptable values are same as `cpu` field of package.json, which comes from `process.arch`.
193
194 #### `os`
195
196 - Default: null
197 - Type: null or String
198
199 Override OS of native modules to install. Acceptable values are same as `os` field of package.json, which comes from `process.platform`.
200
201 #### `workspace`
202
203 - Default:
204 - Type: String (can be set multiple times)
205
206 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.
207
208 Valid values for the `workspace` config are either:
209
210 - Workspace names
211 - Path to a workspace directory
212 - Path to a parent workspace directory (will result in selecting all workspaces within that folder)
213
214 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.
215
216 This value is not exported to the environment for child processes.
217
218 #### `workspaces`
219
220 - Default: null
221 - Type: null or Boolean
222
223 Set to true to run the command in the context of **all** configured workspaces.
224
225 Explicitly setting this to false will cause commands like `install` to ignore workspaces altogether. When not set explicitly:
226
227 - 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.
228
229 This value is not exported to the environment for child processes.
230
231 #### `include-workspace-root`
232
233 - Default: false
234 - Type: Boolean
235
236 Include the workspace root when workspaces are enabled for a command.
237
238 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.
239
240 This value is not exported to the environment for child processes.
241
242 #### `install-links`
243
244 - Default: false
245 - Type: Boolean
246
247 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.
248
249 ### See Also
250
251 - [npm install](/cli/v9/commands/npm-install)
252 - [npm install-ci-test](/cli/v9/commands/npm-install-ci-test)
253 - [npm test](/cli/v9/commands/npm-test)