11cb0ef41Sopenharmony_ci--- 21cb0ef41Sopenharmony_cititle: npm-update 31cb0ef41Sopenharmony_cisection: 1 41cb0ef41Sopenharmony_cidescription: Update packages 51cb0ef41Sopenharmony_ci--- 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci### Synopsis 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci```bash 101cb0ef41Sopenharmony_cinpm update [<pkg>...] 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cialiases: up, upgrade, udpate 131cb0ef41Sopenharmony_ci``` 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci### Description 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciThis command will update all the packages listed to the latest version 181cb0ef41Sopenharmony_ci(specified by the [`tag` config](/using-npm/config#tag)), respecting the semver 191cb0ef41Sopenharmony_ciconstraints of both your package and its dependencies (if they also require the 201cb0ef41Sopenharmony_cisame package). 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciIt will also install missing packages. 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciIf the `-g` flag is specified, this command will update globally installed 251cb0ef41Sopenharmony_cipackages. 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciIf no package name is specified, all packages in the specified location (global 281cb0ef41Sopenharmony_cior local) will be updated. 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciNote that by default `npm update` will not update the semver values of direct 311cb0ef41Sopenharmony_cidependencies in your project `package.json`. If you want to also update 321cb0ef41Sopenharmony_civalues in `package.json` you can run: `npm update --save` (or add the 331cb0ef41Sopenharmony_ci`save=true` option to a [configuration file](/configuring-npm/npmrc) 341cb0ef41Sopenharmony_cito make that the default behavior). 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci### Example 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ciFor the examples below, assume that the current package is `app` and it depends 391cb0ef41Sopenharmony_cion dependencies, `dep1` (`dep2`, .. etc.). The published versions of `dep1` 401cb0ef41Sopenharmony_ciare: 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci```json 431cb0ef41Sopenharmony_ci{ 441cb0ef41Sopenharmony_ci "dist-tags": { "latest": "1.2.2" }, 451cb0ef41Sopenharmony_ci "versions": [ 461cb0ef41Sopenharmony_ci "1.2.2", 471cb0ef41Sopenharmony_ci "1.2.1", 481cb0ef41Sopenharmony_ci "1.2.0", 491cb0ef41Sopenharmony_ci "1.1.2", 501cb0ef41Sopenharmony_ci "1.1.1", 511cb0ef41Sopenharmony_ci "1.0.0", 521cb0ef41Sopenharmony_ci "0.4.1", 531cb0ef41Sopenharmony_ci "0.4.0", 541cb0ef41Sopenharmony_ci "0.2.0" 551cb0ef41Sopenharmony_ci ] 561cb0ef41Sopenharmony_ci} 571cb0ef41Sopenharmony_ci``` 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci#### Caret Dependencies 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ciIf `app`'s `package.json` contains: 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci```json 641cb0ef41Sopenharmony_ci"dependencies": { 651cb0ef41Sopenharmony_ci "dep1": "^1.1.1" 661cb0ef41Sopenharmony_ci} 671cb0ef41Sopenharmony_ci``` 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_ciThen `npm update` will install `dep1@1.2.2`, because `1.2.2` is `latest` and 701cb0ef41Sopenharmony_ci`1.2.2` satisfies `^1.1.1`. 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci#### Tilde Dependencies 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ciHowever, if `app`'s `package.json` contains: 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ci```json 771cb0ef41Sopenharmony_ci"dependencies": { 781cb0ef41Sopenharmony_ci "dep1": "~1.1.1" 791cb0ef41Sopenharmony_ci} 801cb0ef41Sopenharmony_ci``` 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ciIn this case, running `npm update` will install `dep1@1.1.2`. Even though the 831cb0ef41Sopenharmony_ci`latest` tag points to `1.2.2`, this version does not satisfy `~1.1.1`, which is 841cb0ef41Sopenharmony_ciequivalent to `>=1.1.1 <1.2.0`. So the highest-sorting version that satisfies 851cb0ef41Sopenharmony_ci`~1.1.1` is used, which is `1.1.2`. 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci#### Caret Dependencies below 1.0.0 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_ciSuppose `app` has a caret dependency on a version below `1.0.0`, for example: 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_ci```json 921cb0ef41Sopenharmony_ci"dependencies": { 931cb0ef41Sopenharmony_ci "dep1": "^0.2.0" 941cb0ef41Sopenharmony_ci} 951cb0ef41Sopenharmony_ci``` 961cb0ef41Sopenharmony_ci 971cb0ef41Sopenharmony_ci`npm update` will install `dep1@0.2.0`. 981cb0ef41Sopenharmony_ci 991cb0ef41Sopenharmony_ciIf the dependence were on `^0.4.0`: 1001cb0ef41Sopenharmony_ci 1011cb0ef41Sopenharmony_ci```json 1021cb0ef41Sopenharmony_ci"dependencies": { 1031cb0ef41Sopenharmony_ci "dep1": "^0.4.0" 1041cb0ef41Sopenharmony_ci} 1051cb0ef41Sopenharmony_ci``` 1061cb0ef41Sopenharmony_ci 1071cb0ef41Sopenharmony_ciThen `npm update` will install `dep1@0.4.1`, because that is the highest-sorting 1081cb0ef41Sopenharmony_civersion that satisfies `^0.4.0` (`>= 0.4.0 <0.5.0`) 1091cb0ef41Sopenharmony_ci 1101cb0ef41Sopenharmony_ci 1111cb0ef41Sopenharmony_ci#### Subdependencies 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_ciSuppose your app now also has a dependency on `dep2` 1141cb0ef41Sopenharmony_ci 1151cb0ef41Sopenharmony_ci```json 1161cb0ef41Sopenharmony_ci{ 1171cb0ef41Sopenharmony_ci "name": "my-app", 1181cb0ef41Sopenharmony_ci "dependencies": { 1191cb0ef41Sopenharmony_ci "dep1": "^1.0.0", 1201cb0ef41Sopenharmony_ci "dep2": "1.0.0" 1211cb0ef41Sopenharmony_ci } 1221cb0ef41Sopenharmony_ci} 1231cb0ef41Sopenharmony_ci``` 1241cb0ef41Sopenharmony_ci 1251cb0ef41Sopenharmony_ciand `dep2` itself depends on this limited range of `dep1` 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ci```json 1281cb0ef41Sopenharmony_ci{ 1291cb0ef41Sopenharmony_ci"name": "dep2", 1301cb0ef41Sopenharmony_ci "dependencies": { 1311cb0ef41Sopenharmony_ci "dep1": "~1.1.1" 1321cb0ef41Sopenharmony_ci } 1331cb0ef41Sopenharmony_ci} 1341cb0ef41Sopenharmony_ci``` 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ciThen `npm update` will install `dep1@1.1.2` because that is the highest 1371cb0ef41Sopenharmony_civersion that `dep2` allows. npm will prioritize having a single version 1381cb0ef41Sopenharmony_ciof `dep1` in your tree rather than two when that single version can 1391cb0ef41Sopenharmony_cisatisfy the semver requirements of multiple dependencies in your tree. 1401cb0ef41Sopenharmony_ciIn this case if you really did need your package to use a newer version 1411cb0ef41Sopenharmony_ciyou would need to use `npm install`. 1421cb0ef41Sopenharmony_ci 1431cb0ef41Sopenharmony_ci 1441cb0ef41Sopenharmony_ci#### Updating Globally-Installed Packages 1451cb0ef41Sopenharmony_ci 1461cb0ef41Sopenharmony_ci`npm update -g` will apply the `update` action to each globally installed 1471cb0ef41Sopenharmony_cipackage that is `outdated` -- that is, has a version that is different from 1481cb0ef41Sopenharmony_ci`wanted`. 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_ciNote: Globally installed packages are treated as if they are installed with a 1511cb0ef41Sopenharmony_cicaret semver range specified. So if you require to update to `latest` you may 1521cb0ef41Sopenharmony_cineed to run `npm install -g [<pkg>...]` 1531cb0ef41Sopenharmony_ci 1541cb0ef41Sopenharmony_ciNOTE: If a package has been upgraded to a version newer than `latest`, it will 1551cb0ef41Sopenharmony_cibe _downgraded_. 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_ci### Configuration 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_ci#### `save` 1601cb0ef41Sopenharmony_ci 1611cb0ef41Sopenharmony_ci* Default: `true` unless when using `npm update` where it defaults to `false` 1621cb0ef41Sopenharmony_ci* Type: Boolean 1631cb0ef41Sopenharmony_ci 1641cb0ef41Sopenharmony_ciSave installed packages to a `package.json` file as dependencies. 1651cb0ef41Sopenharmony_ci 1661cb0ef41Sopenharmony_ciWhen used with the `npm rm` command, removes the dependency from 1671cb0ef41Sopenharmony_ci`package.json`. 1681cb0ef41Sopenharmony_ci 1691cb0ef41Sopenharmony_ciWill also prevent writing to `package-lock.json` if set to `false`. 1701cb0ef41Sopenharmony_ci 1711cb0ef41Sopenharmony_ci 1721cb0ef41Sopenharmony_ci 1731cb0ef41Sopenharmony_ci#### `global` 1741cb0ef41Sopenharmony_ci 1751cb0ef41Sopenharmony_ci* Default: false 1761cb0ef41Sopenharmony_ci* Type: Boolean 1771cb0ef41Sopenharmony_ci 1781cb0ef41Sopenharmony_ciOperates in "global" mode, so that packages are installed into the `prefix` 1791cb0ef41Sopenharmony_cifolder instead of the current working directory. See 1801cb0ef41Sopenharmony_ci[folders](/configuring-npm/folders) for more on the differences in behavior. 1811cb0ef41Sopenharmony_ci 1821cb0ef41Sopenharmony_ci* packages are installed into the `{prefix}/lib/node_modules` folder, instead 1831cb0ef41Sopenharmony_ci of the current working directory. 1841cb0ef41Sopenharmony_ci* bin files are linked to `{prefix}/bin` 1851cb0ef41Sopenharmony_ci* man pages are linked to `{prefix}/share/man` 1861cb0ef41Sopenharmony_ci 1871cb0ef41Sopenharmony_ci 1881cb0ef41Sopenharmony_ci 1891cb0ef41Sopenharmony_ci#### `install-strategy` 1901cb0ef41Sopenharmony_ci 1911cb0ef41Sopenharmony_ci* Default: "hoisted" 1921cb0ef41Sopenharmony_ci* Type: "hoisted", "nested", "shallow", or "linked" 1931cb0ef41Sopenharmony_ci 1941cb0ef41Sopenharmony_ciSets the strategy for installing packages in node_modules. hoisted 1951cb0ef41Sopenharmony_ci(default): Install non-duplicated in top-level, and duplicated as necessary 1961cb0ef41Sopenharmony_ciwithin directory structure. nested: (formerly --legacy-bundling) install in 1971cb0ef41Sopenharmony_ciplace, no hoisting. shallow (formerly --global-style) only install direct 1981cb0ef41Sopenharmony_cideps at top-level. linked: (experimental) install in node_modules/.store, 1991cb0ef41Sopenharmony_cilink in place, unhoisted. 2001cb0ef41Sopenharmony_ci 2011cb0ef41Sopenharmony_ci 2021cb0ef41Sopenharmony_ci 2031cb0ef41Sopenharmony_ci#### `legacy-bundling` 2041cb0ef41Sopenharmony_ci 2051cb0ef41Sopenharmony_ci* Default: false 2061cb0ef41Sopenharmony_ci* Type: Boolean 2071cb0ef41Sopenharmony_ci* DEPRECATED: This option has been deprecated in favor of 2081cb0ef41Sopenharmony_ci `--install-strategy=nested` 2091cb0ef41Sopenharmony_ci 2101cb0ef41Sopenharmony_ciInstead of hoisting package installs in `node_modules`, install packages in 2111cb0ef41Sopenharmony_cithe same manner that they are depended on. This may cause very deep 2121cb0ef41Sopenharmony_cidirectory structures and duplicate package installs as there is no 2131cb0ef41Sopenharmony_cide-duplicating. Sets `--install-strategy=nested`. 2141cb0ef41Sopenharmony_ci 2151cb0ef41Sopenharmony_ci 2161cb0ef41Sopenharmony_ci 2171cb0ef41Sopenharmony_ci#### `global-style` 2181cb0ef41Sopenharmony_ci 2191cb0ef41Sopenharmony_ci* Default: false 2201cb0ef41Sopenharmony_ci* Type: Boolean 2211cb0ef41Sopenharmony_ci* DEPRECATED: This option has been deprecated in favor of 2221cb0ef41Sopenharmony_ci `--install-strategy=shallow` 2231cb0ef41Sopenharmony_ci 2241cb0ef41Sopenharmony_ciOnly install direct dependencies in the top level `node_modules`, but hoist 2251cb0ef41Sopenharmony_cion deeper dependencies. Sets `--install-strategy=shallow`. 2261cb0ef41Sopenharmony_ci 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_ci 2291cb0ef41Sopenharmony_ci#### `omit` 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_ci* Default: 'dev' if the `NODE_ENV` environment variable is set to 2321cb0ef41Sopenharmony_ci 'production', otherwise empty. 2331cb0ef41Sopenharmony_ci* Type: "dev", "optional", or "peer" (can be set multiple times) 2341cb0ef41Sopenharmony_ci 2351cb0ef41Sopenharmony_ciDependency types to omit from the installation tree on disk. 2361cb0ef41Sopenharmony_ci 2371cb0ef41Sopenharmony_ciNote that these dependencies _are_ still resolved and added to the 2381cb0ef41Sopenharmony_ci`package-lock.json` or `npm-shrinkwrap.json` file. They are just not 2391cb0ef41Sopenharmony_ciphysically installed on disk. 2401cb0ef41Sopenharmony_ci 2411cb0ef41Sopenharmony_ciIf a package type appears in both the `--include` and `--omit` lists, then 2421cb0ef41Sopenharmony_ciit will be included. 2431cb0ef41Sopenharmony_ci 2441cb0ef41Sopenharmony_ciIf the resulting omit list includes `'dev'`, then the `NODE_ENV` environment 2451cb0ef41Sopenharmony_civariable will be set to `'production'` for all lifecycle scripts. 2461cb0ef41Sopenharmony_ci 2471cb0ef41Sopenharmony_ci 2481cb0ef41Sopenharmony_ci 2491cb0ef41Sopenharmony_ci#### `include` 2501cb0ef41Sopenharmony_ci 2511cb0ef41Sopenharmony_ci* Default: 2521cb0ef41Sopenharmony_ci* Type: "prod", "dev", "optional", or "peer" (can be set multiple times) 2531cb0ef41Sopenharmony_ci 2541cb0ef41Sopenharmony_ciOption that allows for defining which types of dependencies to install. 2551cb0ef41Sopenharmony_ci 2561cb0ef41Sopenharmony_ciThis is the inverse of `--omit=<type>`. 2571cb0ef41Sopenharmony_ci 2581cb0ef41Sopenharmony_ciDependency types specified in `--include` will not be omitted, regardless of 2591cb0ef41Sopenharmony_cithe order in which omit/include are specified on the command-line. 2601cb0ef41Sopenharmony_ci 2611cb0ef41Sopenharmony_ci 2621cb0ef41Sopenharmony_ci 2631cb0ef41Sopenharmony_ci#### `strict-peer-deps` 2641cb0ef41Sopenharmony_ci 2651cb0ef41Sopenharmony_ci* Default: false 2661cb0ef41Sopenharmony_ci* Type: Boolean 2671cb0ef41Sopenharmony_ci 2681cb0ef41Sopenharmony_ciIf set to `true`, and `--legacy-peer-deps` is not set, then _any_ 2691cb0ef41Sopenharmony_ciconflicting `peerDependencies` will be treated as an install failure, even 2701cb0ef41Sopenharmony_ciif npm could reasonably guess the appropriate resolution based on non-peer 2711cb0ef41Sopenharmony_cidependency relationships. 2721cb0ef41Sopenharmony_ci 2731cb0ef41Sopenharmony_ciBy default, conflicting `peerDependencies` deep in the dependency graph will 2741cb0ef41Sopenharmony_cibe resolved using the nearest non-peer dependency specification, even if 2751cb0ef41Sopenharmony_cidoing so will result in some packages receiving a peer dependency outside 2761cb0ef41Sopenharmony_cithe range set in their package's `peerDependencies` object. 2771cb0ef41Sopenharmony_ci 2781cb0ef41Sopenharmony_ciWhen such an override is performed, a warning is printed, explaining the 2791cb0ef41Sopenharmony_ciconflict and the packages involved. If `--strict-peer-deps` is set, then 2801cb0ef41Sopenharmony_cithis warning is treated as a failure. 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_ci 2831cb0ef41Sopenharmony_ci 2841cb0ef41Sopenharmony_ci#### `package-lock` 2851cb0ef41Sopenharmony_ci 2861cb0ef41Sopenharmony_ci* Default: true 2871cb0ef41Sopenharmony_ci* Type: Boolean 2881cb0ef41Sopenharmony_ci 2891cb0ef41Sopenharmony_ciIf set to false, then ignore `package-lock.json` files when installing. This 2901cb0ef41Sopenharmony_ciwill also prevent _writing_ `package-lock.json` if `save` is true. 2911cb0ef41Sopenharmony_ci 2921cb0ef41Sopenharmony_ci 2931cb0ef41Sopenharmony_ci 2941cb0ef41Sopenharmony_ci#### `foreground-scripts` 2951cb0ef41Sopenharmony_ci 2961cb0ef41Sopenharmony_ci* Default: `false` unless when using `npm pack` or `npm publish` where it 2971cb0ef41Sopenharmony_ci defaults to `true` 2981cb0ef41Sopenharmony_ci* Type: Boolean 2991cb0ef41Sopenharmony_ci 3001cb0ef41Sopenharmony_ciRun all build scripts (ie, `preinstall`, `install`, and `postinstall`) 3011cb0ef41Sopenharmony_ciscripts for installed packages in the foreground process, sharing standard 3021cb0ef41Sopenharmony_ciinput, output, and error with the main npm process. 3031cb0ef41Sopenharmony_ci 3041cb0ef41Sopenharmony_ciNote that this will generally make installs run slower, and be much noisier, 3051cb0ef41Sopenharmony_cibut can be useful for debugging. 3061cb0ef41Sopenharmony_ci 3071cb0ef41Sopenharmony_ci 3081cb0ef41Sopenharmony_ci 3091cb0ef41Sopenharmony_ci#### `ignore-scripts` 3101cb0ef41Sopenharmony_ci 3111cb0ef41Sopenharmony_ci* Default: false 3121cb0ef41Sopenharmony_ci* Type: Boolean 3131cb0ef41Sopenharmony_ci 3141cb0ef41Sopenharmony_ciIf true, npm does not run scripts specified in package.json files. 3151cb0ef41Sopenharmony_ci 3161cb0ef41Sopenharmony_ciNote that commands explicitly intended to run a particular script, such as 3171cb0ef41Sopenharmony_ci`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script` 3181cb0ef41Sopenharmony_ciwill still run their intended script if `ignore-scripts` is set, but they 3191cb0ef41Sopenharmony_ciwill *not* run any pre- or post-scripts. 3201cb0ef41Sopenharmony_ci 3211cb0ef41Sopenharmony_ci 3221cb0ef41Sopenharmony_ci 3231cb0ef41Sopenharmony_ci#### `audit` 3241cb0ef41Sopenharmony_ci 3251cb0ef41Sopenharmony_ci* Default: true 3261cb0ef41Sopenharmony_ci* Type: Boolean 3271cb0ef41Sopenharmony_ci 3281cb0ef41Sopenharmony_ciWhen "true" submit audit reports alongside the current npm command to the 3291cb0ef41Sopenharmony_cidefault registry and all registries configured for scopes. See the 3301cb0ef41Sopenharmony_cidocumentation for [`npm audit`](/commands/npm-audit) for details on what is 3311cb0ef41Sopenharmony_cisubmitted. 3321cb0ef41Sopenharmony_ci 3331cb0ef41Sopenharmony_ci 3341cb0ef41Sopenharmony_ci 3351cb0ef41Sopenharmony_ci#### `bin-links` 3361cb0ef41Sopenharmony_ci 3371cb0ef41Sopenharmony_ci* Default: true 3381cb0ef41Sopenharmony_ci* Type: Boolean 3391cb0ef41Sopenharmony_ci 3401cb0ef41Sopenharmony_ciTells npm to create symlinks (or `.cmd` shims on Windows) for package 3411cb0ef41Sopenharmony_ciexecutables. 3421cb0ef41Sopenharmony_ci 3431cb0ef41Sopenharmony_ciSet to false to have it not do this. This can be used to work around the 3441cb0ef41Sopenharmony_cifact that some file systems don't support symlinks, even on ostensibly Unix 3451cb0ef41Sopenharmony_cisystems. 3461cb0ef41Sopenharmony_ci 3471cb0ef41Sopenharmony_ci 3481cb0ef41Sopenharmony_ci 3491cb0ef41Sopenharmony_ci#### `fund` 3501cb0ef41Sopenharmony_ci 3511cb0ef41Sopenharmony_ci* Default: true 3521cb0ef41Sopenharmony_ci* Type: Boolean 3531cb0ef41Sopenharmony_ci 3541cb0ef41Sopenharmony_ciWhen "true" displays the message at the end of each `npm install` 3551cb0ef41Sopenharmony_ciacknowledging the number of dependencies looking for funding. See [`npm 3561cb0ef41Sopenharmony_cifund`](/commands/npm-fund) for details. 3571cb0ef41Sopenharmony_ci 3581cb0ef41Sopenharmony_ci 3591cb0ef41Sopenharmony_ci 3601cb0ef41Sopenharmony_ci#### `dry-run` 3611cb0ef41Sopenharmony_ci 3621cb0ef41Sopenharmony_ci* Default: false 3631cb0ef41Sopenharmony_ci* Type: Boolean 3641cb0ef41Sopenharmony_ci 3651cb0ef41Sopenharmony_ciIndicates that you don't want npm to make any changes and that it should 3661cb0ef41Sopenharmony_cionly report what it would have done. This can be passed into any of the 3671cb0ef41Sopenharmony_cicommands that modify your local installation, eg, `install`, `update`, 3681cb0ef41Sopenharmony_ci`dedupe`, `uninstall`, as well as `pack` and `publish`. 3691cb0ef41Sopenharmony_ci 3701cb0ef41Sopenharmony_ciNote: This is NOT honored by other network related commands, eg `dist-tags`, 3711cb0ef41Sopenharmony_ci`owner`, etc. 3721cb0ef41Sopenharmony_ci 3731cb0ef41Sopenharmony_ci 3741cb0ef41Sopenharmony_ci 3751cb0ef41Sopenharmony_ci#### `workspace` 3761cb0ef41Sopenharmony_ci 3771cb0ef41Sopenharmony_ci* Default: 3781cb0ef41Sopenharmony_ci* Type: String (can be set multiple times) 3791cb0ef41Sopenharmony_ci 3801cb0ef41Sopenharmony_ciEnable running a command in the context of the configured workspaces of the 3811cb0ef41Sopenharmony_cicurrent project while filtering by running only the workspaces defined by 3821cb0ef41Sopenharmony_cithis configuration option. 3831cb0ef41Sopenharmony_ci 3841cb0ef41Sopenharmony_ciValid values for the `workspace` config are either: 3851cb0ef41Sopenharmony_ci 3861cb0ef41Sopenharmony_ci* Workspace names 3871cb0ef41Sopenharmony_ci* Path to a workspace directory 3881cb0ef41Sopenharmony_ci* Path to a parent workspace directory (will result in selecting all 3891cb0ef41Sopenharmony_ci workspaces within that folder) 3901cb0ef41Sopenharmony_ci 3911cb0ef41Sopenharmony_ciWhen set for the `npm init` command, this may be set to the folder of a 3921cb0ef41Sopenharmony_ciworkspace which does not yet exist, to create the folder and set it up as a 3931cb0ef41Sopenharmony_cibrand new workspace within the project. 3941cb0ef41Sopenharmony_ci 3951cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes. 3961cb0ef41Sopenharmony_ci 3971cb0ef41Sopenharmony_ci#### `workspaces` 3981cb0ef41Sopenharmony_ci 3991cb0ef41Sopenharmony_ci* Default: null 4001cb0ef41Sopenharmony_ci* Type: null or Boolean 4011cb0ef41Sopenharmony_ci 4021cb0ef41Sopenharmony_ciSet to true to run the command in the context of **all** configured 4031cb0ef41Sopenharmony_ciworkspaces. 4041cb0ef41Sopenharmony_ci 4051cb0ef41Sopenharmony_ciExplicitly setting this to false will cause commands like `install` to 4061cb0ef41Sopenharmony_ciignore workspaces altogether. When not set explicitly: 4071cb0ef41Sopenharmony_ci 4081cb0ef41Sopenharmony_ci- Commands that operate on the `node_modules` tree (install, update, etc.) 4091cb0ef41Sopenharmony_ciwill link workspaces into the `node_modules` folder. - Commands that do 4101cb0ef41Sopenharmony_ciother things (test, exec, publish, etc.) will operate on the root project, 4111cb0ef41Sopenharmony_ci_unless_ one or more workspaces are specified in the `workspace` config. 4121cb0ef41Sopenharmony_ci 4131cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes. 4141cb0ef41Sopenharmony_ci 4151cb0ef41Sopenharmony_ci#### `include-workspace-root` 4161cb0ef41Sopenharmony_ci 4171cb0ef41Sopenharmony_ci* Default: false 4181cb0ef41Sopenharmony_ci* Type: Boolean 4191cb0ef41Sopenharmony_ci 4201cb0ef41Sopenharmony_ciInclude the workspace root when workspaces are enabled for a command. 4211cb0ef41Sopenharmony_ci 4221cb0ef41Sopenharmony_ciWhen false, specifying individual workspaces via the `workspace` config, or 4231cb0ef41Sopenharmony_ciall workspaces via the `workspaces` flag, will cause npm to operate only on 4241cb0ef41Sopenharmony_cithe specified workspaces, and not on the root project. 4251cb0ef41Sopenharmony_ci 4261cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes. 4271cb0ef41Sopenharmony_ci 4281cb0ef41Sopenharmony_ci#### `install-links` 4291cb0ef41Sopenharmony_ci 4301cb0ef41Sopenharmony_ci* Default: false 4311cb0ef41Sopenharmony_ci* Type: Boolean 4321cb0ef41Sopenharmony_ci 4331cb0ef41Sopenharmony_ciWhen set file: protocol dependencies will be packed and installed as regular 4341cb0ef41Sopenharmony_cidependencies instead of creating a symlink. This option has no effect on 4351cb0ef41Sopenharmony_ciworkspaces. 4361cb0ef41Sopenharmony_ci 4371cb0ef41Sopenharmony_ci 4381cb0ef41Sopenharmony_ci 4391cb0ef41Sopenharmony_ci### See Also 4401cb0ef41Sopenharmony_ci 4411cb0ef41Sopenharmony_ci* [npm install](/commands/npm-install) 4421cb0ef41Sopenharmony_ci* [npm outdated](/commands/npm-outdated) 4431cb0ef41Sopenharmony_ci* [npm shrinkwrap](/commands/npm-shrinkwrap) 4441cb0ef41Sopenharmony_ci* [npm registry](/using-npm/registry) 4451cb0ef41Sopenharmony_ci* [npm folders](/configuring-npm/folders) 4461cb0ef41Sopenharmony_ci* [npm ls](/commands/npm-ls) 447