11cb0ef41Sopenharmony_ci---
21cb0ef41Sopenharmony_cititle: npm-install
31cb0ef41Sopenharmony_cisection: 1
41cb0ef41Sopenharmony_cidescription: Install a package
51cb0ef41Sopenharmony_ci---
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci### Synopsis
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci```bash
101cb0ef41Sopenharmony_cinpm install [<package-spec> ...]
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cialiases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall
131cb0ef41Sopenharmony_ci```
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci### Description
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciThis command installs a package and any packages that it depends on. If the
181cb0ef41Sopenharmony_cipackage has a package-lock, or an npm shrinkwrap file, or a yarn lock file,
191cb0ef41Sopenharmony_cithe installation of dependencies will be driven by that, respecting the
201cb0ef41Sopenharmony_cifollowing order of precedence:
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci* `npm-shrinkwrap.json`
231cb0ef41Sopenharmony_ci* `package-lock.json`
241cb0ef41Sopenharmony_ci* `yarn.lock`
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciSee [package-lock.json](/configuring-npm/package-lock-json) and
271cb0ef41Sopenharmony_ci[`npm shrinkwrap`](/commands/npm-shrinkwrap).
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ciA `package` is:
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci* a) a folder containing a program described by a
321cb0ef41Sopenharmony_ci  [`package.json`](/configuring-npm/package-json) file
331cb0ef41Sopenharmony_ci* b) a gzipped tarball containing (a)
341cb0ef41Sopenharmony_ci* c) a url that resolves to (b)
351cb0ef41Sopenharmony_ci* d) a `<name>@<version>` that is published on the registry (see
361cb0ef41Sopenharmony_ci  [`registry`](/using-npm/registry)) with (c)
371cb0ef41Sopenharmony_ci* e) a `<name>@<tag>` (see [`npm dist-tag`](/commands/npm-dist-tag)) that
381cb0ef41Sopenharmony_ci  points to (d)
391cb0ef41Sopenharmony_ci* f) a `<name>` that has a "latest" tag satisfying (e)
401cb0ef41Sopenharmony_ci* g) a `<git remote url>` that resolves to (a)
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ciEven if you never publish your package, you can still get a lot of benefits
431cb0ef41Sopenharmony_ciof using npm if you just want to write a node program (a), and perhaps if
441cb0ef41Sopenharmony_ciyou also want to be able to easily install it elsewhere after packing it up
451cb0ef41Sopenharmony_ciinto a tarball (b).
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci* `npm install` (in a package directory, no arguments):
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci    Install the dependencies to the local `node_modules` folder.
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci    In global mode (ie, with `-g` or `--global` appended to the command),
531cb0ef41Sopenharmony_ci    it installs the current package context (ie, the current working
541cb0ef41Sopenharmony_ci    directory) as a global package.
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ci    By default, `npm install` will install all modules listed as
571cb0ef41Sopenharmony_ci    dependencies in [`package.json`](/configuring-npm/package-json).
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci    With the `--production` flag (or when the `NODE_ENV` environment
601cb0ef41Sopenharmony_ci    variable is set to `production`), npm will not install modules listed
611cb0ef41Sopenharmony_ci    in `devDependencies`. To install all modules listed in both
621cb0ef41Sopenharmony_ci    `dependencies` and `devDependencies` when `NODE_ENV` environment
631cb0ef41Sopenharmony_ci    variable is set to `production`, you can use `--production=false`.
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci    > NOTE: The `--production` flag has no particular meaning when adding a
661cb0ef41Sopenharmony_ci    dependency to a project.
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_ci* `npm install <folder>`:
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ci    If `<folder>` sits inside the root of your project, its dependencies will be installed and may
711cb0ef41Sopenharmony_ci    be hoisted to the top-level `node_modules` as they would for other
721cb0ef41Sopenharmony_ci    types of dependencies. If `<folder>` sits outside the root of your project,
731cb0ef41Sopenharmony_ci    *npm will not install the package dependencies* in the directory `<folder>`,
741cb0ef41Sopenharmony_ci    but it will create a symlink to `<folder>`.
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_ci    > NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use the `--install-links` option.
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci    Example:
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ci    ```bash
811cb0ef41Sopenharmony_ci    npm install ../../other-package --install-links
821cb0ef41Sopenharmony_ci    npm install ./sub-package
831cb0ef41Sopenharmony_ci    ```
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ci* `npm install <tarball file>`:
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci    Install a package that is sitting on the filesystem.  Note: if you just
881cb0ef41Sopenharmony_ci    want to link a dev directory into your npm root, you can do this more
891cb0ef41Sopenharmony_ci    easily by using [`npm link`](/commands/npm-link).
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ci    Tarball requirements:
921cb0ef41Sopenharmony_ci    * The filename *must* use `.tar`, `.tar.gz`, or `.tgz` as the
931cb0ef41Sopenharmony_ci      extension.
941cb0ef41Sopenharmony_ci    * The package contents should reside in a subfolder inside the tarball
951cb0ef41Sopenharmony_ci      (usually it is called `package/`). npm strips one directory layer
961cb0ef41Sopenharmony_ci      when installing the package (an equivalent of `tar x
971cb0ef41Sopenharmony_ci      --strip-components=1` is run).
981cb0ef41Sopenharmony_ci    * The package must contain a `package.json` file with `name` and
991cb0ef41Sopenharmony_ci      `version` properties.
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci    Example:
1021cb0ef41Sopenharmony_ci
1031cb0ef41Sopenharmony_ci    ```bash
1041cb0ef41Sopenharmony_ci    npm install ./package.tgz
1051cb0ef41Sopenharmony_ci    ```
1061cb0ef41Sopenharmony_ci
1071cb0ef41Sopenharmony_ci* `npm install <tarball url>`:
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_ci    Fetch the tarball url, and then install it.  In order to distinguish between
1101cb0ef41Sopenharmony_ci    this and other options, the argument must start with "http://" or "https://"
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci    Example:
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ci    ```bash
1151cb0ef41Sopenharmony_ci    npm install https://github.com/indexzero/forever/tarball/v0.5.6
1161cb0ef41Sopenharmony_ci    ```
1171cb0ef41Sopenharmony_ci
1181cb0ef41Sopenharmony_ci* `npm install [<@scope>/]<name>`:
1191cb0ef41Sopenharmony_ci
1201cb0ef41Sopenharmony_ci    Do a `<name>@<tag>` install, where `<tag>` is the "tag" config. (See
1211cb0ef41Sopenharmony_ci    [`config`](/using-npm/config#tag). The config's default value is `latest`.)
1221cb0ef41Sopenharmony_ci
1231cb0ef41Sopenharmony_ci    In most cases, this will install the version of the modules tagged as
1241cb0ef41Sopenharmony_ci    `latest` on the npm registry.
1251cb0ef41Sopenharmony_ci
1261cb0ef41Sopenharmony_ci    Example:
1271cb0ef41Sopenharmony_ci
1281cb0ef41Sopenharmony_ci    ```bash
1291cb0ef41Sopenharmony_ci    npm install sax
1301cb0ef41Sopenharmony_ci    ```
1311cb0ef41Sopenharmony_ci
1321cb0ef41Sopenharmony_ci    `npm install` saves any specified packages into `dependencies` by default.
1331cb0ef41Sopenharmony_ci    Additionally, you can control where and how they get saved with some
1341cb0ef41Sopenharmony_ci    additional flags:
1351cb0ef41Sopenharmony_ci
1361cb0ef41Sopenharmony_ci    * `-P, --save-prod`: Package will appear in your `dependencies`. This
1371cb0ef41Sopenharmony_ci      is the default unless `-D` or `-O` are present.
1381cb0ef41Sopenharmony_ci
1391cb0ef41Sopenharmony_ci    * `-D, --save-dev`: Package will appear in your `devDependencies`.
1401cb0ef41Sopenharmony_ci
1411cb0ef41Sopenharmony_ci    * `-O, --save-optional`: Package will appear in your
1421cb0ef41Sopenharmony_ci      `optionalDependencies`.
1431cb0ef41Sopenharmony_ci
1441cb0ef41Sopenharmony_ci    * `--no-save`: Prevents saving to `dependencies`.
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ci    When using any of the above options to save dependencies to your
1471cb0ef41Sopenharmony_ci    package.json, there are two additional, optional flags:
1481cb0ef41Sopenharmony_ci
1491cb0ef41Sopenharmony_ci    * `-E, --save-exact`: Saved dependencies will be configured with an
1501cb0ef41Sopenharmony_ci      exact version rather than using npm's default semver range operator.
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_ci    * `-B, --save-bundle`: Saved dependencies will also be added to your
1531cb0ef41Sopenharmony_ci      `bundleDependencies` list.
1541cb0ef41Sopenharmony_ci
1551cb0ef41Sopenharmony_ci    Further, if you have an `npm-shrinkwrap.json` or `package-lock.json`
1561cb0ef41Sopenharmony_ci    then it will be updated as well.
1571cb0ef41Sopenharmony_ci
1581cb0ef41Sopenharmony_ci    `<scope>` is optional. The package will be downloaded from the registry
1591cb0ef41Sopenharmony_ci    associated with the specified scope. If no registry is associated with
1601cb0ef41Sopenharmony_ci    the given scope the default registry is assumed. See
1611cb0ef41Sopenharmony_ci    [`scope`](/using-npm/scope).
1621cb0ef41Sopenharmony_ci
1631cb0ef41Sopenharmony_ci    Note: if you do not include the @-symbol on your scope name, npm will
1641cb0ef41Sopenharmony_ci    interpret this as a GitHub repository instead, see below. Scopes names
1651cb0ef41Sopenharmony_ci    must also be followed by a slash.
1661cb0ef41Sopenharmony_ci
1671cb0ef41Sopenharmony_ci    Examples:
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci    ```bash
1701cb0ef41Sopenharmony_ci    npm install sax
1711cb0ef41Sopenharmony_ci    npm install githubname/reponame
1721cb0ef41Sopenharmony_ci    npm install @myorg/privatepackage
1731cb0ef41Sopenharmony_ci    npm install node-tap --save-dev
1741cb0ef41Sopenharmony_ci    npm install dtrace-provider --save-optional
1751cb0ef41Sopenharmony_ci    npm install readable-stream --save-exact
1761cb0ef41Sopenharmony_ci    npm install ansi-regex --save-bundle
1771cb0ef41Sopenharmony_ci    ```
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ci    **Note**: If there is a file or folder named `<name>` in the current
1801cb0ef41Sopenharmony_ci    working directory, then it will try to install that, and only try to
1811cb0ef41Sopenharmony_ci    fetch the package by name if it is not valid.
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_ci* `npm install <alias>@npm:<name>`:
1841cb0ef41Sopenharmony_ci
1851cb0ef41Sopenharmony_ci    Install a package under a custom alias. Allows multiple versions of
1861cb0ef41Sopenharmony_ci    a same-name package side-by-side, more convenient import names for
1871cb0ef41Sopenharmony_ci    packages with otherwise long ones, and using git forks replacements
1881cb0ef41Sopenharmony_ci    or forked npm packages as replacements. Aliasing works only on your
1891cb0ef41Sopenharmony_ci    project and does not rename packages in transitive dependencies.
1901cb0ef41Sopenharmony_ci    Aliases should follow the naming conventions stated in
1911cb0ef41Sopenharmony_ci    [`validate-npm-package-name`](https://www.npmjs.com/package/validate-npm-package-name#naming-rules).
1921cb0ef41Sopenharmony_ci
1931cb0ef41Sopenharmony_ci    Examples:
1941cb0ef41Sopenharmony_ci
1951cb0ef41Sopenharmony_ci    ```bash
1961cb0ef41Sopenharmony_ci    npm install my-react@npm:react
1971cb0ef41Sopenharmony_ci    npm install jquery2@npm:jquery@2
1981cb0ef41Sopenharmony_ci    npm install jquery3@npm:jquery@3
1991cb0ef41Sopenharmony_ci    npm install npa@npm:npm-package-arg
2001cb0ef41Sopenharmony_ci    ```
2011cb0ef41Sopenharmony_ci
2021cb0ef41Sopenharmony_ci* `npm install [<@scope>/]<name>@<tag>`:
2031cb0ef41Sopenharmony_ci
2041cb0ef41Sopenharmony_ci    Install the version of the package that is referenced by the specified tag.
2051cb0ef41Sopenharmony_ci    If the tag does not exist in the registry data for that package, then this
2061cb0ef41Sopenharmony_ci    will fail.
2071cb0ef41Sopenharmony_ci
2081cb0ef41Sopenharmony_ci    Example:
2091cb0ef41Sopenharmony_ci
2101cb0ef41Sopenharmony_ci    ```bash
2111cb0ef41Sopenharmony_ci    npm install sax@latest
2121cb0ef41Sopenharmony_ci    npm install @myorg/mypackage@latest
2131cb0ef41Sopenharmony_ci    ```
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_ci* `npm install [<@scope>/]<name>@<version>`:
2161cb0ef41Sopenharmony_ci
2171cb0ef41Sopenharmony_ci    Install the specified version of the package.  This will fail if the
2181cb0ef41Sopenharmony_ci    version has not been published to the registry.
2191cb0ef41Sopenharmony_ci
2201cb0ef41Sopenharmony_ci    Example:
2211cb0ef41Sopenharmony_ci
2221cb0ef41Sopenharmony_ci    ```bash
2231cb0ef41Sopenharmony_ci    npm install sax@0.1.1
2241cb0ef41Sopenharmony_ci    npm install @myorg/privatepackage@1.5.0
2251cb0ef41Sopenharmony_ci    ```
2261cb0ef41Sopenharmony_ci
2271cb0ef41Sopenharmony_ci* `npm install [<@scope>/]<name>@<version range>`:
2281cb0ef41Sopenharmony_ci
2291cb0ef41Sopenharmony_ci    Install a version of the package matching the specified version range.
2301cb0ef41Sopenharmony_ci    This will follow the same rules for resolving dependencies described in
2311cb0ef41Sopenharmony_ci    [`package.json`](/configuring-npm/package-json).
2321cb0ef41Sopenharmony_ci
2331cb0ef41Sopenharmony_ci    Note that most version ranges must be put in quotes so that your shell
2341cb0ef41Sopenharmony_ci    will treat it as a single argument.
2351cb0ef41Sopenharmony_ci
2361cb0ef41Sopenharmony_ci    Example:
2371cb0ef41Sopenharmony_ci
2381cb0ef41Sopenharmony_ci    ```bash
2391cb0ef41Sopenharmony_ci    npm install sax@">=0.1.0 <0.2.0"
2401cb0ef41Sopenharmony_ci    npm install @myorg/privatepackage@"16 - 17"
2411cb0ef41Sopenharmony_ci    ```
2421cb0ef41Sopenharmony_ci
2431cb0ef41Sopenharmony_ci* `npm install <git remote url>`:
2441cb0ef41Sopenharmony_ci
2451cb0ef41Sopenharmony_ci    Installs the package from the hosted git provider, cloning it with
2461cb0ef41Sopenharmony_ci    `git`.  For a full git remote url, only that URL will be attempted.
2471cb0ef41Sopenharmony_ci
2481cb0ef41Sopenharmony_ci    ```bash
2491cb0ef41Sopenharmony_ci    <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
2501cb0ef41Sopenharmony_ci    ```
2511cb0ef41Sopenharmony_ci
2521cb0ef41Sopenharmony_ci    `<protocol>` is one of `git`, `git+ssh`, `git+http`, `git+https`, or
2531cb0ef41Sopenharmony_ci    `git+file`.
2541cb0ef41Sopenharmony_ci
2551cb0ef41Sopenharmony_ci    If `#<commit-ish>` is provided, it will be used to clone exactly that
2561cb0ef41Sopenharmony_ci    commit. If the commit-ish has the format `#semver:<semver>`, `<semver>`
2571cb0ef41Sopenharmony_ci    can be any valid semver range or exact version, and npm will look for
2581cb0ef41Sopenharmony_ci    any tags or refs matching that range in the remote repository, much as
2591cb0ef41Sopenharmony_ci    it would for a registry dependency. If neither `#<commit-ish>` or
2601cb0ef41Sopenharmony_ci    `#semver:<semver>` is specified, then the default branch of the
2611cb0ef41Sopenharmony_ci    repository is used.
2621cb0ef41Sopenharmony_ci
2631cb0ef41Sopenharmony_ci    If the repository makes use of submodules, those submodules will be
2641cb0ef41Sopenharmony_ci    cloned as well.
2651cb0ef41Sopenharmony_ci
2661cb0ef41Sopenharmony_ci    If the package being installed contains a `prepare` script, its
2671cb0ef41Sopenharmony_ci    `dependencies` and `devDependencies` will be installed, and the prepare
2681cb0ef41Sopenharmony_ci    script will be run, before the package is packaged and installed.
2691cb0ef41Sopenharmony_ci
2701cb0ef41Sopenharmony_ci    The following git environment variables are recognized by npm and will
2711cb0ef41Sopenharmony_ci    be added to the environment when running git:
2721cb0ef41Sopenharmony_ci
2731cb0ef41Sopenharmony_ci    * `GIT_ASKPASS`
2741cb0ef41Sopenharmony_ci    * `GIT_EXEC_PATH`
2751cb0ef41Sopenharmony_ci    * `GIT_PROXY_COMMAND`
2761cb0ef41Sopenharmony_ci    * `GIT_SSH`
2771cb0ef41Sopenharmony_ci    * `GIT_SSH_COMMAND`
2781cb0ef41Sopenharmony_ci    * `GIT_SSL_CAINFO`
2791cb0ef41Sopenharmony_ci    * `GIT_SSL_NO_VERIFY`
2801cb0ef41Sopenharmony_ci
2811cb0ef41Sopenharmony_ci    See the git man page for details.
2821cb0ef41Sopenharmony_ci
2831cb0ef41Sopenharmony_ci    Examples:
2841cb0ef41Sopenharmony_ci
2851cb0ef41Sopenharmony_ci    ```bash
2861cb0ef41Sopenharmony_ci    npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
2871cb0ef41Sopenharmony_ci    npm install git+ssh://git@github.com:npm/cli#pull/273
2881cb0ef41Sopenharmony_ci    npm install git+ssh://git@github.com:npm/cli#semver:^5.0
2891cb0ef41Sopenharmony_ci    npm install git+https://isaacs@github.com/npm/cli.git
2901cb0ef41Sopenharmony_ci    npm install git://github.com/npm/cli.git#v1.0.27
2911cb0ef41Sopenharmony_ci    GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install git+ssh://git@github.com:npm/cli.git
2921cb0ef41Sopenharmony_ci    ```
2931cb0ef41Sopenharmony_ci
2941cb0ef41Sopenharmony_ci* `npm install <githubname>/<githubrepo>[#<commit-ish>]`:
2951cb0ef41Sopenharmony_ci* `npm install github:<githubname>/<githubrepo>[#<commit-ish>]`:
2961cb0ef41Sopenharmony_ci
2971cb0ef41Sopenharmony_ci    Install the package at `https://github.com/githubname/githubrepo` by
2981cb0ef41Sopenharmony_ci    attempting to clone it using `git`.
2991cb0ef41Sopenharmony_ci
3001cb0ef41Sopenharmony_ci    If `#<commit-ish>` is provided, it will be used to clone exactly that
3011cb0ef41Sopenharmony_ci    commit. If the commit-ish has the format `#semver:<semver>`, `<semver>`
3021cb0ef41Sopenharmony_ci    can be any valid semver range or exact version, and npm will look for
3031cb0ef41Sopenharmony_ci    any tags or refs matching that range in the remote repository, much as
3041cb0ef41Sopenharmony_ci    it would for a registry dependency. If neither `#<commit-ish>` or
3051cb0ef41Sopenharmony_ci    `#semver:<semver>` is specified, then the default branch is used.
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ci    As with regular git dependencies, `dependencies` and `devDependencies`
3081cb0ef41Sopenharmony_ci    will be installed if the package has a `prepare` script before the
3091cb0ef41Sopenharmony_ci    package is done installing.
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci    Examples:
3121cb0ef41Sopenharmony_ci
3131cb0ef41Sopenharmony_ci    ```bash
3141cb0ef41Sopenharmony_ci    npm install mygithubuser/myproject
3151cb0ef41Sopenharmony_ci    npm install github:mygithubuser/myproject
3161cb0ef41Sopenharmony_ci   ```
3171cb0ef41Sopenharmony_ci
3181cb0ef41Sopenharmony_ci* `npm install gist:[<githubname>/]<gistID>[#<commit-ish>|#semver:<semver>]`:
3191cb0ef41Sopenharmony_ci
3201cb0ef41Sopenharmony_ci    Install the package at `https://gist.github.com/gistID` by attempting to
3211cb0ef41Sopenharmony_ci    clone it using `git`. The GitHub username associated with the gist is
3221cb0ef41Sopenharmony_ci    optional and will not be saved in `package.json`.
3231cb0ef41Sopenharmony_ci
3241cb0ef41Sopenharmony_ci    As with regular git dependencies, `dependencies` and `devDependencies` will
3251cb0ef41Sopenharmony_ci    be installed if the package has a `prepare` script before the package is
3261cb0ef41Sopenharmony_ci    done installing.
3271cb0ef41Sopenharmony_ci
3281cb0ef41Sopenharmony_ci    Example:
3291cb0ef41Sopenharmony_ci
3301cb0ef41Sopenharmony_ci    ```bash
3311cb0ef41Sopenharmony_ci    npm install gist:101a11beef
3321cb0ef41Sopenharmony_ci    ```
3331cb0ef41Sopenharmony_ci
3341cb0ef41Sopenharmony_ci* `npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]`:
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci    Install the package at `https://bitbucket.org/bitbucketname/bitbucketrepo`
3371cb0ef41Sopenharmony_ci    by attempting to clone it using `git`.
3381cb0ef41Sopenharmony_ci
3391cb0ef41Sopenharmony_ci    If `#<commit-ish>` is provided, it will be used to clone exactly that
3401cb0ef41Sopenharmony_ci    commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
3411cb0ef41Sopenharmony_ci    be any valid semver range or exact version, and npm will look for any tags
3421cb0ef41Sopenharmony_ci    or refs matching that range in the remote repository, much as it would for a
3431cb0ef41Sopenharmony_ci    registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
3441cb0ef41Sopenharmony_ci    specified, then `master` is used.
3451cb0ef41Sopenharmony_ci
3461cb0ef41Sopenharmony_ci    As with regular git dependencies, `dependencies` and `devDependencies` will
3471cb0ef41Sopenharmony_ci    be installed if the package has a `prepare` script before the package is
3481cb0ef41Sopenharmony_ci    done installing.
3491cb0ef41Sopenharmony_ci
3501cb0ef41Sopenharmony_ci    Example:
3511cb0ef41Sopenharmony_ci
3521cb0ef41Sopenharmony_ci    ```bash
3531cb0ef41Sopenharmony_ci    npm install bitbucket:mybitbucketuser/myproject
3541cb0ef41Sopenharmony_ci    ```
3551cb0ef41Sopenharmony_ci
3561cb0ef41Sopenharmony_ci* `npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]`:
3571cb0ef41Sopenharmony_ci
3581cb0ef41Sopenharmony_ci    Install the package at `https://gitlab.com/gitlabname/gitlabrepo`
3591cb0ef41Sopenharmony_ci    by attempting to clone it using `git`.
3601cb0ef41Sopenharmony_ci
3611cb0ef41Sopenharmony_ci    If `#<commit-ish>` is provided, it will be used to clone exactly that
3621cb0ef41Sopenharmony_ci    commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
3631cb0ef41Sopenharmony_ci    be any valid semver range or exact version, and npm will look for any tags
3641cb0ef41Sopenharmony_ci    or refs matching that range in the remote repository, much as it would for a
3651cb0ef41Sopenharmony_ci    registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
3661cb0ef41Sopenharmony_ci    specified, then `master` is used.
3671cb0ef41Sopenharmony_ci
3681cb0ef41Sopenharmony_ci    As with regular git dependencies, `dependencies` and `devDependencies` will
3691cb0ef41Sopenharmony_ci    be installed if the package has a `prepare` script before the package is
3701cb0ef41Sopenharmony_ci    done installing.
3711cb0ef41Sopenharmony_ci
3721cb0ef41Sopenharmony_ci    Example:
3731cb0ef41Sopenharmony_ci
3741cb0ef41Sopenharmony_ci    ```bash
3751cb0ef41Sopenharmony_ci    npm install gitlab:mygitlabuser/myproject
3761cb0ef41Sopenharmony_ci    npm install gitlab:myusr/myproj#semver:^5.0
3771cb0ef41Sopenharmony_ci    ```
3781cb0ef41Sopenharmony_ci
3791cb0ef41Sopenharmony_ciYou may combine multiple arguments and even multiple types of arguments.
3801cb0ef41Sopenharmony_ciFor example:
3811cb0ef41Sopenharmony_ci
3821cb0ef41Sopenharmony_ci```bash
3831cb0ef41Sopenharmony_cinpm install sax@">=0.1.0 <0.2.0" bench supervisor
3841cb0ef41Sopenharmony_ci```
3851cb0ef41Sopenharmony_ci
3861cb0ef41Sopenharmony_ciThe `--tag` argument will apply to all of the specified install targets. If
3871cb0ef41Sopenharmony_cia tag with the given name exists, the tagged version is preferred over
3881cb0ef41Sopenharmony_cinewer versions.
3891cb0ef41Sopenharmony_ci
3901cb0ef41Sopenharmony_ciThe `--dry-run` argument will report in the usual way what the install
3911cb0ef41Sopenharmony_ciwould have done without actually installing anything.
3921cb0ef41Sopenharmony_ci
3931cb0ef41Sopenharmony_ciThe `--package-lock-only` argument will only update the
3941cb0ef41Sopenharmony_ci`package-lock.json`, instead of checking `node_modules` and downloading
3951cb0ef41Sopenharmony_cidependencies.
3961cb0ef41Sopenharmony_ci
3971cb0ef41Sopenharmony_ciThe `-f` or `--force` argument will force npm to fetch remote resources
3981cb0ef41Sopenharmony_cieven if a local copy exists on disk.
3991cb0ef41Sopenharmony_ci
4001cb0ef41Sopenharmony_ci```bash
4011cb0ef41Sopenharmony_cinpm install sax --force
4021cb0ef41Sopenharmony_ci```
4031cb0ef41Sopenharmony_ci
4041cb0ef41Sopenharmony_ci### Configuration
4051cb0ef41Sopenharmony_ci
4061cb0ef41Sopenharmony_ciSee the [`config`](/using-npm/config) help doc.  Many of the configuration
4071cb0ef41Sopenharmony_ciparams have some effect on installation, since that's most of what npm
4081cb0ef41Sopenharmony_cidoes.
4091cb0ef41Sopenharmony_ci
4101cb0ef41Sopenharmony_ciThese are some of the most common options related to installation.
4111cb0ef41Sopenharmony_ci
4121cb0ef41Sopenharmony_ci#### `save`
4131cb0ef41Sopenharmony_ci
4141cb0ef41Sopenharmony_ci* Default: `true` unless when using `npm update` where it defaults to `false`
4151cb0ef41Sopenharmony_ci* Type: Boolean
4161cb0ef41Sopenharmony_ci
4171cb0ef41Sopenharmony_ciSave installed packages to a `package.json` file as dependencies.
4181cb0ef41Sopenharmony_ci
4191cb0ef41Sopenharmony_ciWhen used with the `npm rm` command, removes the dependency from
4201cb0ef41Sopenharmony_ci`package.json`.
4211cb0ef41Sopenharmony_ci
4221cb0ef41Sopenharmony_ciWill also prevent writing to `package-lock.json` if set to `false`.
4231cb0ef41Sopenharmony_ci
4241cb0ef41Sopenharmony_ci
4251cb0ef41Sopenharmony_ci
4261cb0ef41Sopenharmony_ci#### `save-exact`
4271cb0ef41Sopenharmony_ci
4281cb0ef41Sopenharmony_ci* Default: false
4291cb0ef41Sopenharmony_ci* Type: Boolean
4301cb0ef41Sopenharmony_ci
4311cb0ef41Sopenharmony_ciDependencies saved to package.json will be configured with an exact version
4321cb0ef41Sopenharmony_cirather than using npm's default semver range operator.
4331cb0ef41Sopenharmony_ci
4341cb0ef41Sopenharmony_ci
4351cb0ef41Sopenharmony_ci
4361cb0ef41Sopenharmony_ci#### `global`
4371cb0ef41Sopenharmony_ci
4381cb0ef41Sopenharmony_ci* Default: false
4391cb0ef41Sopenharmony_ci* Type: Boolean
4401cb0ef41Sopenharmony_ci
4411cb0ef41Sopenharmony_ciOperates in "global" mode, so that packages are installed into the `prefix`
4421cb0ef41Sopenharmony_cifolder instead of the current working directory. See
4431cb0ef41Sopenharmony_ci[folders](/configuring-npm/folders) for more on the differences in behavior.
4441cb0ef41Sopenharmony_ci
4451cb0ef41Sopenharmony_ci* packages are installed into the `{prefix}/lib/node_modules` folder, instead
4461cb0ef41Sopenharmony_ci  of the current working directory.
4471cb0ef41Sopenharmony_ci* bin files are linked to `{prefix}/bin`
4481cb0ef41Sopenharmony_ci* man pages are linked to `{prefix}/share/man`
4491cb0ef41Sopenharmony_ci
4501cb0ef41Sopenharmony_ci
4511cb0ef41Sopenharmony_ci
4521cb0ef41Sopenharmony_ci#### `install-strategy`
4531cb0ef41Sopenharmony_ci
4541cb0ef41Sopenharmony_ci* Default: "hoisted"
4551cb0ef41Sopenharmony_ci* Type: "hoisted", "nested", "shallow", or "linked"
4561cb0ef41Sopenharmony_ci
4571cb0ef41Sopenharmony_ciSets the strategy for installing packages in node_modules. hoisted
4581cb0ef41Sopenharmony_ci(default): Install non-duplicated in top-level, and duplicated as necessary
4591cb0ef41Sopenharmony_ciwithin directory structure. nested: (formerly --legacy-bundling) install in
4601cb0ef41Sopenharmony_ciplace, no hoisting. shallow (formerly --global-style) only install direct
4611cb0ef41Sopenharmony_cideps at top-level. linked: (experimental) install in node_modules/.store,
4621cb0ef41Sopenharmony_cilink in place, unhoisted.
4631cb0ef41Sopenharmony_ci
4641cb0ef41Sopenharmony_ci
4651cb0ef41Sopenharmony_ci
4661cb0ef41Sopenharmony_ci#### `legacy-bundling`
4671cb0ef41Sopenharmony_ci
4681cb0ef41Sopenharmony_ci* Default: false
4691cb0ef41Sopenharmony_ci* Type: Boolean
4701cb0ef41Sopenharmony_ci* DEPRECATED: This option has been deprecated in favor of
4711cb0ef41Sopenharmony_ci  `--install-strategy=nested`
4721cb0ef41Sopenharmony_ci
4731cb0ef41Sopenharmony_ciInstead of hoisting package installs in `node_modules`, install packages in
4741cb0ef41Sopenharmony_cithe same manner that they are depended on. This may cause very deep
4751cb0ef41Sopenharmony_cidirectory structures and duplicate package installs as there is no
4761cb0ef41Sopenharmony_cide-duplicating. Sets `--install-strategy=nested`.
4771cb0ef41Sopenharmony_ci
4781cb0ef41Sopenharmony_ci
4791cb0ef41Sopenharmony_ci
4801cb0ef41Sopenharmony_ci#### `global-style`
4811cb0ef41Sopenharmony_ci
4821cb0ef41Sopenharmony_ci* Default: false
4831cb0ef41Sopenharmony_ci* Type: Boolean
4841cb0ef41Sopenharmony_ci* DEPRECATED: This option has been deprecated in favor of
4851cb0ef41Sopenharmony_ci  `--install-strategy=shallow`
4861cb0ef41Sopenharmony_ci
4871cb0ef41Sopenharmony_ciOnly install direct dependencies in the top level `node_modules`, but hoist
4881cb0ef41Sopenharmony_cion deeper dependencies. Sets `--install-strategy=shallow`.
4891cb0ef41Sopenharmony_ci
4901cb0ef41Sopenharmony_ci
4911cb0ef41Sopenharmony_ci
4921cb0ef41Sopenharmony_ci#### `omit`
4931cb0ef41Sopenharmony_ci
4941cb0ef41Sopenharmony_ci* Default: 'dev' if the `NODE_ENV` environment variable is set to
4951cb0ef41Sopenharmony_ci  'production', otherwise empty.
4961cb0ef41Sopenharmony_ci* Type: "dev", "optional", or "peer" (can be set multiple times)
4971cb0ef41Sopenharmony_ci
4981cb0ef41Sopenharmony_ciDependency types to omit from the installation tree on disk.
4991cb0ef41Sopenharmony_ci
5001cb0ef41Sopenharmony_ciNote that these dependencies _are_ still resolved and added to the
5011cb0ef41Sopenharmony_ci`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
5021cb0ef41Sopenharmony_ciphysically installed on disk.
5031cb0ef41Sopenharmony_ci
5041cb0ef41Sopenharmony_ciIf a package type appears in both the `--include` and `--omit` lists, then
5051cb0ef41Sopenharmony_ciit will be included.
5061cb0ef41Sopenharmony_ci
5071cb0ef41Sopenharmony_ciIf the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
5081cb0ef41Sopenharmony_civariable will be set to `'production'` for all lifecycle scripts.
5091cb0ef41Sopenharmony_ci
5101cb0ef41Sopenharmony_ci
5111cb0ef41Sopenharmony_ci
5121cb0ef41Sopenharmony_ci#### `include`
5131cb0ef41Sopenharmony_ci
5141cb0ef41Sopenharmony_ci* Default:
5151cb0ef41Sopenharmony_ci* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
5161cb0ef41Sopenharmony_ci
5171cb0ef41Sopenharmony_ciOption that allows for defining which types of dependencies to install.
5181cb0ef41Sopenharmony_ci
5191cb0ef41Sopenharmony_ciThis is the inverse of `--omit=<type>`.
5201cb0ef41Sopenharmony_ci
5211cb0ef41Sopenharmony_ciDependency types specified in `--include` will not be omitted, regardless of
5221cb0ef41Sopenharmony_cithe order in which omit/include are specified on the command-line.
5231cb0ef41Sopenharmony_ci
5241cb0ef41Sopenharmony_ci
5251cb0ef41Sopenharmony_ci
5261cb0ef41Sopenharmony_ci#### `strict-peer-deps`
5271cb0ef41Sopenharmony_ci
5281cb0ef41Sopenharmony_ci* Default: false
5291cb0ef41Sopenharmony_ci* Type: Boolean
5301cb0ef41Sopenharmony_ci
5311cb0ef41Sopenharmony_ciIf set to `true`, and `--legacy-peer-deps` is not set, then _any_
5321cb0ef41Sopenharmony_ciconflicting `peerDependencies` will be treated as an install failure, even
5331cb0ef41Sopenharmony_ciif npm could reasonably guess the appropriate resolution based on non-peer
5341cb0ef41Sopenharmony_cidependency relationships.
5351cb0ef41Sopenharmony_ci
5361cb0ef41Sopenharmony_ciBy default, conflicting `peerDependencies` deep in the dependency graph will
5371cb0ef41Sopenharmony_cibe resolved using the nearest non-peer dependency specification, even if
5381cb0ef41Sopenharmony_cidoing so will result in some packages receiving a peer dependency outside
5391cb0ef41Sopenharmony_cithe range set in their package's `peerDependencies` object.
5401cb0ef41Sopenharmony_ci
5411cb0ef41Sopenharmony_ciWhen such an override is performed, a warning is printed, explaining the
5421cb0ef41Sopenharmony_ciconflict and the packages involved. If `--strict-peer-deps` is set, then
5431cb0ef41Sopenharmony_cithis warning is treated as a failure.
5441cb0ef41Sopenharmony_ci
5451cb0ef41Sopenharmony_ci
5461cb0ef41Sopenharmony_ci
5471cb0ef41Sopenharmony_ci#### `prefer-dedupe`
5481cb0ef41Sopenharmony_ci
5491cb0ef41Sopenharmony_ci* Default: false
5501cb0ef41Sopenharmony_ci* Type: Boolean
5511cb0ef41Sopenharmony_ci
5521cb0ef41Sopenharmony_ciPrefer to deduplicate packages if possible, rather than choosing a newer
5531cb0ef41Sopenharmony_civersion of a dependency.
5541cb0ef41Sopenharmony_ci
5551cb0ef41Sopenharmony_ci
5561cb0ef41Sopenharmony_ci
5571cb0ef41Sopenharmony_ci#### `package-lock`
5581cb0ef41Sopenharmony_ci
5591cb0ef41Sopenharmony_ci* Default: true
5601cb0ef41Sopenharmony_ci* Type: Boolean
5611cb0ef41Sopenharmony_ci
5621cb0ef41Sopenharmony_ciIf set to false, then ignore `package-lock.json` files when installing. This
5631cb0ef41Sopenharmony_ciwill also prevent _writing_ `package-lock.json` if `save` is true.
5641cb0ef41Sopenharmony_ci
5651cb0ef41Sopenharmony_ci
5661cb0ef41Sopenharmony_ci
5671cb0ef41Sopenharmony_ci#### `package-lock-only`
5681cb0ef41Sopenharmony_ci
5691cb0ef41Sopenharmony_ci* Default: false
5701cb0ef41Sopenharmony_ci* Type: Boolean
5711cb0ef41Sopenharmony_ci
5721cb0ef41Sopenharmony_ciIf set to true, the current operation will only use the `package-lock.json`,
5731cb0ef41Sopenharmony_ciignoring `node_modules`.
5741cb0ef41Sopenharmony_ci
5751cb0ef41Sopenharmony_ciFor `update` this means only the `package-lock.json` will be updated,
5761cb0ef41Sopenharmony_ciinstead of checking `node_modules` and downloading dependencies.
5771cb0ef41Sopenharmony_ci
5781cb0ef41Sopenharmony_ciFor `list` this means the output will be based on the tree described by the
5791cb0ef41Sopenharmony_ci`package-lock.json`, rather than the contents of `node_modules`.
5801cb0ef41Sopenharmony_ci
5811cb0ef41Sopenharmony_ci
5821cb0ef41Sopenharmony_ci
5831cb0ef41Sopenharmony_ci#### `foreground-scripts`
5841cb0ef41Sopenharmony_ci
5851cb0ef41Sopenharmony_ci* Default: `false` unless when using `npm pack` or `npm publish` where it
5861cb0ef41Sopenharmony_ci  defaults to `true`
5871cb0ef41Sopenharmony_ci* Type: Boolean
5881cb0ef41Sopenharmony_ci
5891cb0ef41Sopenharmony_ciRun all build scripts (ie, `preinstall`, `install`, and `postinstall`)
5901cb0ef41Sopenharmony_ciscripts for installed packages in the foreground process, sharing standard
5911cb0ef41Sopenharmony_ciinput, output, and error with the main npm process.
5921cb0ef41Sopenharmony_ci
5931cb0ef41Sopenharmony_ciNote that this will generally make installs run slower, and be much noisier,
5941cb0ef41Sopenharmony_cibut can be useful for debugging.
5951cb0ef41Sopenharmony_ci
5961cb0ef41Sopenharmony_ci
5971cb0ef41Sopenharmony_ci
5981cb0ef41Sopenharmony_ci#### `ignore-scripts`
5991cb0ef41Sopenharmony_ci
6001cb0ef41Sopenharmony_ci* Default: false
6011cb0ef41Sopenharmony_ci* Type: Boolean
6021cb0ef41Sopenharmony_ci
6031cb0ef41Sopenharmony_ciIf true, npm does not run scripts specified in package.json files.
6041cb0ef41Sopenharmony_ci
6051cb0ef41Sopenharmony_ciNote that commands explicitly intended to run a particular script, such as
6061cb0ef41Sopenharmony_ci`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script`
6071cb0ef41Sopenharmony_ciwill still run their intended script if `ignore-scripts` is set, but they
6081cb0ef41Sopenharmony_ciwill *not* run any pre- or post-scripts.
6091cb0ef41Sopenharmony_ci
6101cb0ef41Sopenharmony_ci
6111cb0ef41Sopenharmony_ci
6121cb0ef41Sopenharmony_ci#### `audit`
6131cb0ef41Sopenharmony_ci
6141cb0ef41Sopenharmony_ci* Default: true
6151cb0ef41Sopenharmony_ci* Type: Boolean
6161cb0ef41Sopenharmony_ci
6171cb0ef41Sopenharmony_ciWhen "true" submit audit reports alongside the current npm command to the
6181cb0ef41Sopenharmony_cidefault registry and all registries configured for scopes. See the
6191cb0ef41Sopenharmony_cidocumentation for [`npm audit`](/commands/npm-audit) for details on what is
6201cb0ef41Sopenharmony_cisubmitted.
6211cb0ef41Sopenharmony_ci
6221cb0ef41Sopenharmony_ci
6231cb0ef41Sopenharmony_ci
6241cb0ef41Sopenharmony_ci#### `bin-links`
6251cb0ef41Sopenharmony_ci
6261cb0ef41Sopenharmony_ci* Default: true
6271cb0ef41Sopenharmony_ci* Type: Boolean
6281cb0ef41Sopenharmony_ci
6291cb0ef41Sopenharmony_ciTells npm to create symlinks (or `.cmd` shims on Windows) for package
6301cb0ef41Sopenharmony_ciexecutables.
6311cb0ef41Sopenharmony_ci
6321cb0ef41Sopenharmony_ciSet to false to have it not do this. This can be used to work around the
6331cb0ef41Sopenharmony_cifact that some file systems don't support symlinks, even on ostensibly Unix
6341cb0ef41Sopenharmony_cisystems.
6351cb0ef41Sopenharmony_ci
6361cb0ef41Sopenharmony_ci
6371cb0ef41Sopenharmony_ci
6381cb0ef41Sopenharmony_ci#### `fund`
6391cb0ef41Sopenharmony_ci
6401cb0ef41Sopenharmony_ci* Default: true
6411cb0ef41Sopenharmony_ci* Type: Boolean
6421cb0ef41Sopenharmony_ci
6431cb0ef41Sopenharmony_ciWhen "true" displays the message at the end of each `npm install`
6441cb0ef41Sopenharmony_ciacknowledging the number of dependencies looking for funding. See [`npm
6451cb0ef41Sopenharmony_cifund`](/commands/npm-fund) for details.
6461cb0ef41Sopenharmony_ci
6471cb0ef41Sopenharmony_ci
6481cb0ef41Sopenharmony_ci
6491cb0ef41Sopenharmony_ci#### `dry-run`
6501cb0ef41Sopenharmony_ci
6511cb0ef41Sopenharmony_ci* Default: false
6521cb0ef41Sopenharmony_ci* Type: Boolean
6531cb0ef41Sopenharmony_ci
6541cb0ef41Sopenharmony_ciIndicates that you don't want npm to make any changes and that it should
6551cb0ef41Sopenharmony_cionly report what it would have done. This can be passed into any of the
6561cb0ef41Sopenharmony_cicommands that modify your local installation, eg, `install`, `update`,
6571cb0ef41Sopenharmony_ci`dedupe`, `uninstall`, as well as `pack` and `publish`.
6581cb0ef41Sopenharmony_ci
6591cb0ef41Sopenharmony_ciNote: This is NOT honored by other network related commands, eg `dist-tags`,
6601cb0ef41Sopenharmony_ci`owner`, etc.
6611cb0ef41Sopenharmony_ci
6621cb0ef41Sopenharmony_ci
6631cb0ef41Sopenharmony_ci
6641cb0ef41Sopenharmony_ci#### `cpu`
6651cb0ef41Sopenharmony_ci
6661cb0ef41Sopenharmony_ci* Default: null
6671cb0ef41Sopenharmony_ci* Type: null or String
6681cb0ef41Sopenharmony_ci
6691cb0ef41Sopenharmony_ciOverride CPU architecture of native modules to install. Acceptable values
6701cb0ef41Sopenharmony_ciare same as `cpu` field of package.json, which comes from `process.arch`.
6711cb0ef41Sopenharmony_ci
6721cb0ef41Sopenharmony_ci
6731cb0ef41Sopenharmony_ci
6741cb0ef41Sopenharmony_ci#### `os`
6751cb0ef41Sopenharmony_ci
6761cb0ef41Sopenharmony_ci* Default: null
6771cb0ef41Sopenharmony_ci* Type: null or String
6781cb0ef41Sopenharmony_ci
6791cb0ef41Sopenharmony_ciOverride OS of native modules to install. Acceptable values are same as `os`
6801cb0ef41Sopenharmony_cifield of package.json, which comes from `process.platform`.
6811cb0ef41Sopenharmony_ci
6821cb0ef41Sopenharmony_ci
6831cb0ef41Sopenharmony_ci
6841cb0ef41Sopenharmony_ci#### `libc`
6851cb0ef41Sopenharmony_ci
6861cb0ef41Sopenharmony_ci* Default: null
6871cb0ef41Sopenharmony_ci* Type: null or String
6881cb0ef41Sopenharmony_ci
6891cb0ef41Sopenharmony_ciOverride libc of native modules to install. Acceptable values are same as
6901cb0ef41Sopenharmony_ci`libc` field of package.json
6911cb0ef41Sopenharmony_ci
6921cb0ef41Sopenharmony_ci
6931cb0ef41Sopenharmony_ci
6941cb0ef41Sopenharmony_ci#### `workspace`
6951cb0ef41Sopenharmony_ci
6961cb0ef41Sopenharmony_ci* Default:
6971cb0ef41Sopenharmony_ci* Type: String (can be set multiple times)
6981cb0ef41Sopenharmony_ci
6991cb0ef41Sopenharmony_ciEnable running a command in the context of the configured workspaces of the
7001cb0ef41Sopenharmony_cicurrent project while filtering by running only the workspaces defined by
7011cb0ef41Sopenharmony_cithis configuration option.
7021cb0ef41Sopenharmony_ci
7031cb0ef41Sopenharmony_ciValid values for the `workspace` config are either:
7041cb0ef41Sopenharmony_ci
7051cb0ef41Sopenharmony_ci* Workspace names
7061cb0ef41Sopenharmony_ci* Path to a workspace directory
7071cb0ef41Sopenharmony_ci* Path to a parent workspace directory (will result in selecting all
7081cb0ef41Sopenharmony_ci  workspaces within that folder)
7091cb0ef41Sopenharmony_ci
7101cb0ef41Sopenharmony_ciWhen set for the `npm init` command, this may be set to the folder of a
7111cb0ef41Sopenharmony_ciworkspace which does not yet exist, to create the folder and set it up as a
7121cb0ef41Sopenharmony_cibrand new workspace within the project.
7131cb0ef41Sopenharmony_ci
7141cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes.
7151cb0ef41Sopenharmony_ci
7161cb0ef41Sopenharmony_ci#### `workspaces`
7171cb0ef41Sopenharmony_ci
7181cb0ef41Sopenharmony_ci* Default: null
7191cb0ef41Sopenharmony_ci* Type: null or Boolean
7201cb0ef41Sopenharmony_ci
7211cb0ef41Sopenharmony_ciSet to true to run the command in the context of **all** configured
7221cb0ef41Sopenharmony_ciworkspaces.
7231cb0ef41Sopenharmony_ci
7241cb0ef41Sopenharmony_ciExplicitly setting this to false will cause commands like `install` to
7251cb0ef41Sopenharmony_ciignore workspaces altogether. When not set explicitly:
7261cb0ef41Sopenharmony_ci
7271cb0ef41Sopenharmony_ci- Commands that operate on the `node_modules` tree (install, update, etc.)
7281cb0ef41Sopenharmony_ciwill link workspaces into the `node_modules` folder. - Commands that do
7291cb0ef41Sopenharmony_ciother things (test, exec, publish, etc.) will operate on the root project,
7301cb0ef41Sopenharmony_ci_unless_ one or more workspaces are specified in the `workspace` config.
7311cb0ef41Sopenharmony_ci
7321cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes.
7331cb0ef41Sopenharmony_ci
7341cb0ef41Sopenharmony_ci#### `include-workspace-root`
7351cb0ef41Sopenharmony_ci
7361cb0ef41Sopenharmony_ci* Default: false
7371cb0ef41Sopenharmony_ci* Type: Boolean
7381cb0ef41Sopenharmony_ci
7391cb0ef41Sopenharmony_ciInclude the workspace root when workspaces are enabled for a command.
7401cb0ef41Sopenharmony_ci
7411cb0ef41Sopenharmony_ciWhen false, specifying individual workspaces via the `workspace` config, or
7421cb0ef41Sopenharmony_ciall workspaces via the `workspaces` flag, will cause npm to operate only on
7431cb0ef41Sopenharmony_cithe specified workspaces, and not on the root project.
7441cb0ef41Sopenharmony_ci
7451cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes.
7461cb0ef41Sopenharmony_ci
7471cb0ef41Sopenharmony_ci#### `install-links`
7481cb0ef41Sopenharmony_ci
7491cb0ef41Sopenharmony_ci* Default: false
7501cb0ef41Sopenharmony_ci* Type: Boolean
7511cb0ef41Sopenharmony_ci
7521cb0ef41Sopenharmony_ciWhen set file: protocol dependencies will be packed and installed as regular
7531cb0ef41Sopenharmony_cidependencies instead of creating a symlink. This option has no effect on
7541cb0ef41Sopenharmony_ciworkspaces.
7551cb0ef41Sopenharmony_ci
7561cb0ef41Sopenharmony_ci
7571cb0ef41Sopenharmony_ci
7581cb0ef41Sopenharmony_ci### Algorithm
7591cb0ef41Sopenharmony_ci
7601cb0ef41Sopenharmony_ciGiven a `package{dep}` structure: `A{B,C}, B{C}, C{D}`,
7611cb0ef41Sopenharmony_cithe npm install algorithm produces:
7621cb0ef41Sopenharmony_ci
7631cb0ef41Sopenharmony_ci```bash
7641cb0ef41Sopenharmony_ciA
7651cb0ef41Sopenharmony_ci+-- B
7661cb0ef41Sopenharmony_ci+-- C
7671cb0ef41Sopenharmony_ci+-- D
7681cb0ef41Sopenharmony_ci```
7691cb0ef41Sopenharmony_ci
7701cb0ef41Sopenharmony_ciThat is, the dependency from B to C is satisfied by the fact that A already
7711cb0ef41Sopenharmony_cicaused C to be installed at a higher level. D is still installed at the top
7721cb0ef41Sopenharmony_cilevel because nothing conflicts with it.
7731cb0ef41Sopenharmony_ci
7741cb0ef41Sopenharmony_ciFor `A{B,C}, B{C,D@1}, C{D@2}`, this algorithm produces:
7751cb0ef41Sopenharmony_ci
7761cb0ef41Sopenharmony_ci```bash
7771cb0ef41Sopenharmony_ciA
7781cb0ef41Sopenharmony_ci+-- B
7791cb0ef41Sopenharmony_ci+-- C
7801cb0ef41Sopenharmony_ci   `-- D@2
7811cb0ef41Sopenharmony_ci+-- D@1
7821cb0ef41Sopenharmony_ci```
7831cb0ef41Sopenharmony_ci
7841cb0ef41Sopenharmony_ciBecause B's D@1 will be installed in the top-level, C now has to install
7851cb0ef41Sopenharmony_ciD@2 privately for itself. This algorithm is deterministic, but different
7861cb0ef41Sopenharmony_citrees may be produced if two dependencies are requested for installation in
7871cb0ef41Sopenharmony_cia different order.
7881cb0ef41Sopenharmony_ci
7891cb0ef41Sopenharmony_ciSee [folders](/configuring-npm/folders) for a more detailed description of
7901cb0ef41Sopenharmony_cithe specific folder structures that npm creates.
7911cb0ef41Sopenharmony_ci
7921cb0ef41Sopenharmony_ci### See Also
7931cb0ef41Sopenharmony_ci
7941cb0ef41Sopenharmony_ci* [npm folders](/configuring-npm/folders)
7951cb0ef41Sopenharmony_ci* [npm update](/commands/npm-update)
7961cb0ef41Sopenharmony_ci* [npm audit](/commands/npm-audit)
7971cb0ef41Sopenharmony_ci* [npm fund](/commands/npm-fund)
7981cb0ef41Sopenharmony_ci* [npm link](/commands/npm-link)
7991cb0ef41Sopenharmony_ci* [npm rebuild](/commands/npm-rebuild)
8001cb0ef41Sopenharmony_ci* [npm scripts](/using-npm/scripts)
8011cb0ef41Sopenharmony_ci* [npm config](/commands/npm-config)
8021cb0ef41Sopenharmony_ci* [npmrc](/configuring-npm/npmrc)
8031cb0ef41Sopenharmony_ci* [npm registry](/using-npm/registry)
8041cb0ef41Sopenharmony_ci* [npm dist-tag](/commands/npm-dist-tag)
8051cb0ef41Sopenharmony_ci* [npm uninstall](/commands/npm-uninstall)
8061cb0ef41Sopenharmony_ci* [npm shrinkwrap](/commands/npm-shrinkwrap)
8071cb0ef41Sopenharmony_ci* [package.json](/configuring-npm/package-json)
8081cb0ef41Sopenharmony_ci* [workspaces](/using-npm/workspaces)
809