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