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#### `strict-peer-deps` 123 124* Default: false 125* Type: Boolean 126 127If set to `true`, and `--legacy-peer-deps` is not set, then _any_ 128conflicting `peerDependencies` will be treated as an install failure, even 129if npm could reasonably guess the appropriate resolution based on non-peer 130dependency relationships. 131 132By default, conflicting `peerDependencies` deep in the dependency graph will 133be resolved using the nearest non-peer dependency specification, even if 134doing so will result in some packages receiving a peer dependency outside 135the range set in their package's `peerDependencies` object. 136 137When such an override is performed, a warning is printed, explaining the 138conflict and the packages involved. If `--strict-peer-deps` is set, then 139this warning is treated as a failure. 140 141 142 143#### `prefer-dedupe` 144 145* Default: false 146* Type: Boolean 147 148Prefer to deduplicate packages if possible, rather than choosing a newer 149version of a dependency. 150 151 152 153#### `package-lock` 154 155* Default: true 156* Type: Boolean 157 158If set to false, then ignore `package-lock.json` files when installing. This 159will also prevent _writing_ `package-lock.json` if `save` is true. 160 161 162 163#### `package-lock-only` 164 165* Default: false 166* Type: Boolean 167 168If set to true, the current operation will only use the `package-lock.json`, 169ignoring `node_modules`. 170 171For `update` this means only the `package-lock.json` will be updated, 172instead of checking `node_modules` and downloading dependencies. 173 174For `list` this means the output will be based on the tree described by the 175`package-lock.json`, rather than the contents of `node_modules`. 176 177 178 179#### `foreground-scripts` 180 181* Default: false 182* Type: Boolean 183 184Run all build scripts (ie, `preinstall`, `install`, and `postinstall`) 185scripts for installed packages in the foreground process, sharing standard 186input, output, and error with the main npm process. 187 188Note that this will generally make installs run slower, and be much noisier, 189but can be useful for debugging. 190 191 192 193#### `ignore-scripts` 194 195* Default: false 196* Type: Boolean 197 198If true, npm does not run scripts specified in package.json files. 199 200Note that commands explicitly intended to run a particular script, such as 201`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script` 202will still run their intended script if `ignore-scripts` is set, but they 203will *not* run any pre- or post-scripts. 204 205 206 207#### `audit` 208 209* Default: true 210* Type: Boolean 211 212When "true" submit audit reports alongside the current npm command to the 213default registry and all registries configured for scopes. See the 214documentation for [`npm audit`](/commands/npm-audit) for details on what is 215submitted. 216 217 218 219#### `bin-links` 220 221* Default: true 222* Type: Boolean 223 224Tells npm to create symlinks (or `.cmd` shims on Windows) for package 225executables. 226 227Set to false to have it not do this. This can be used to work around the 228fact that some file systems don't support symlinks, even on ostensibly Unix 229systems. 230 231 232 233#### `fund` 234 235* Default: true 236* Type: Boolean 237 238When "true" displays the message at the end of each `npm install` 239acknowledging the number of dependencies looking for funding. See [`npm 240fund`](/commands/npm-fund) for details. 241 242 243 244#### `dry-run` 245 246* Default: false 247* Type: Boolean 248 249Indicates that you don't want npm to make any changes and that it should 250only report what it would have done. This can be passed into any of the 251commands that modify your local installation, eg, `install`, `update`, 252`dedupe`, `uninstall`, as well as `pack` and `publish`. 253 254Note: This is NOT honored by other network related commands, eg `dist-tags`, 255`owner`, etc. 256 257 258 259#### `workspace` 260 261* Default: 262* Type: String (can be set multiple times) 263 264Enable running a command in the context of the configured workspaces of the 265current project while filtering by running only the workspaces defined by 266this configuration option. 267 268Valid values for the `workspace` config are either: 269 270* Workspace names 271* Path to a workspace directory 272* Path to a parent workspace directory (will result in selecting all 273 workspaces within that folder) 274 275When set for the `npm init` command, this may be set to the folder of a 276workspace which does not yet exist, to create the folder and set it up as a 277brand new workspace within the project. 278 279This value is not exported to the environment for child processes. 280 281#### `workspaces` 282 283* Default: null 284* Type: null or Boolean 285 286Set to true to run the command in the context of **all** configured 287workspaces. 288 289Explicitly setting this to false will cause commands like `install` to 290ignore workspaces altogether. When not set explicitly: 291 292- Commands that operate on the `node_modules` tree (install, update, etc.) 293will link workspaces into the `node_modules` folder. - Commands that do 294other things (test, exec, publish, etc.) will operate on the root project, 295_unless_ one or more workspaces are specified in the `workspace` config. 296 297This value is not exported to the environment for child processes. 298 299#### `include-workspace-root` 300 301* Default: false 302* Type: Boolean 303 304Include the workspace root when workspaces are enabled for a command. 305 306When false, specifying individual workspaces via the `workspace` config, or 307all workspaces via the `workspaces` flag, will cause npm to operate only on 308the specified workspaces, and not on the root project. 309 310This value is not exported to the environment for child processes. 311 312#### `install-links` 313 314* Default: false 315* Type: Boolean 316 317When set file: protocol dependencies will be packed and installed as regular 318dependencies instead of creating a symlink. This option has no effect on 319workspaces. 320 321 322 323### See Also 324 325* [npm install](/commands/npm-install) 326* [npm install-ci-test](/commands/npm-install-ci-test) 327* [npm test](/commands/npm-test) 328