11cb0ef41Sopenharmony_ci<!DOCTYPE html><html><head>
21cb0ef41Sopenharmony_ci<meta charset="utf-8">
31cb0ef41Sopenharmony_ci<title>package.json</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="packagejson">package.json</h1>
1401cb0ef41Sopenharmony_ci<span class="description">Specifics of npm's package.json handling</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="#description">Description</a></li><li><a href="#name">name</a></li><li><a href="#version">version</a></li><li><a href="#description2">description</a></li><li><a href="#keywords">keywords</a></li><li><a href="#homepage">homepage</a></li><li><a href="#bugs">bugs</a></li><li><a href="#license">license</a></li><li><a href="#people-fields-author-contributors">people fields: author, contributors</a></li><li><a href="#funding">funding</a></li><li><a href="#files">files</a></li><li><a href="#main">main</a></li><li><a href="#browser">browser</a></li><li><a href="#bin">bin</a></li><li><a href="#man">man</a></li><li><a href="#directories">directories</a></li><ul><li><a href="#directoriesbin">directories.bin</a></li><li><a href="#directoriesman">directories.man</a></li></ul><li><a href="#repository">repository</a></li><li><a href="#scripts">scripts</a></li><li><a href="#config">config</a></li><li><a href="#dependencies">dependencies</a></li><ul><li><a href="#urls-as-dependencies">URLs as Dependencies</a></li><li><a href="#git-urls-as-dependencies">Git URLs as Dependencies</a></li><li><a href="#github-urls">GitHub URLs</a></li><li><a href="#local-paths">Local Paths</a></li></ul><li><a href="#devdependencies">devDependencies</a></li><li><a href="#peerdependencies">peerDependencies</a></li><li><a href="#peerdependenciesmeta">peerDependenciesMeta</a></li><li><a href="#bundledependencies">bundleDependencies</a></li><li><a href="#optionaldependencies">optionalDependencies</a></li><li><a href="#overrides">overrides</a></li><li><a href="#engines">engines</a></li><li><a href="#os">os</a></li><li><a href="#cpu">cpu</a></li><li><a href="#private">private</a></li><li><a href="#publishconfig">publishConfig</a></li><li><a href="#workspaces">workspaces</a></li><li><a href="#default-values">DEFAULT VALUES</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="description">Description</h3>
1491cb0ef41Sopenharmony_ci<p>This document is all you need to know about what's required in your
1501cb0ef41Sopenharmony_cipackage.json file.  It must be actual JSON, not just a JavaScript object
1511cb0ef41Sopenharmony_ciliteral.</p>
1521cb0ef41Sopenharmony_ci<p>A lot of the behavior described in this document is affected by the config
1531cb0ef41Sopenharmony_cisettings described in <a href="../using-npm/config.html"><code>config</code></a>.</p>
1541cb0ef41Sopenharmony_ci<h3 id="name">name</h3>
1551cb0ef41Sopenharmony_ci<p>If you plan to publish your package, the <em>most</em> important things in your
1561cb0ef41Sopenharmony_cipackage.json are the name and version fields as they will be required. The
1571cb0ef41Sopenharmony_ciname and version together form an identifier that is assumed to be
1581cb0ef41Sopenharmony_cicompletely unique.  Changes to the package should come along with changes
1591cb0ef41Sopenharmony_cito the version. If you don't plan to publish your package, the name and
1601cb0ef41Sopenharmony_civersion fields are optional.</p>
1611cb0ef41Sopenharmony_ci<p>The name is what your thing is called.</p>
1621cb0ef41Sopenharmony_ci<p>Some rules:</p>
1631cb0ef41Sopenharmony_ci<ul>
1641cb0ef41Sopenharmony_ci<li>The name must be less than or equal to 214 characters. This includes the
1651cb0ef41Sopenharmony_ciscope for scoped packages.</li>
1661cb0ef41Sopenharmony_ci<li>The names of scoped packages can begin with a dot or an underscore. This
1671cb0ef41Sopenharmony_ciis not permitted without a scope.</li>
1681cb0ef41Sopenharmony_ci<li>New packages must not have uppercase letters in the name.</li>
1691cb0ef41Sopenharmony_ci<li>The name ends up being part of a URL, an argument on the command line,
1701cb0ef41Sopenharmony_ciand a folder name. Therefore, the name can't contain any non-URL-safe
1711cb0ef41Sopenharmony_cicharacters.</li>
1721cb0ef41Sopenharmony_ci</ul>
1731cb0ef41Sopenharmony_ci<p>Some tips:</p>
1741cb0ef41Sopenharmony_ci<ul>
1751cb0ef41Sopenharmony_ci<li>Don't use the same name as a core Node module.</li>
1761cb0ef41Sopenharmony_ci<li>Don't put "js" or "node" in the name.  It's assumed that it's js, since
1771cb0ef41Sopenharmony_ciyou're writing a package.json file, and you can specify the engine using
1781cb0ef41Sopenharmony_cithe "engines" field.  (See below.)</li>
1791cb0ef41Sopenharmony_ci<li>The name will probably be passed as an argument to require(), so it
1801cb0ef41Sopenharmony_cishould be something short, but also reasonably descriptive.</li>
1811cb0ef41Sopenharmony_ci<li>You may want to check the npm registry to see if there's something by
1821cb0ef41Sopenharmony_cithat name already, before you get too attached to it.
1831cb0ef41Sopenharmony_ci<a href="https://www.npmjs.com/">https://www.npmjs.com/</a></li>
1841cb0ef41Sopenharmony_ci</ul>
1851cb0ef41Sopenharmony_ci<p>A name can be optionally prefixed by a scope, e.g. <code>@myorg/mypackage</code>. See
1861cb0ef41Sopenharmony_ci<a href="../using-npm/scope.html"><code>scope</code></a> for more detail.</p>
1871cb0ef41Sopenharmony_ci<h3 id="version">version</h3>
1881cb0ef41Sopenharmony_ci<p>If you plan to publish your package, the <em>most</em> important things in your
1891cb0ef41Sopenharmony_cipackage.json are the name and version fields as they will be required. The
1901cb0ef41Sopenharmony_ciname and version together form an identifier that is assumed to be
1911cb0ef41Sopenharmony_cicompletely unique.  Changes to the package should come along with changes
1921cb0ef41Sopenharmony_cito the version. If you don't plan to publish your package, the name and
1931cb0ef41Sopenharmony_civersion fields are optional.</p>
1941cb0ef41Sopenharmony_ci<p>Version must be parseable by
1951cb0ef41Sopenharmony_ci<a href="https://github.com/npm/node-semver">node-semver</a>, which is bundled with
1961cb0ef41Sopenharmony_cinpm as a dependency.  (<code>npm install semver</code> to use it yourself.)</p>
1971cb0ef41Sopenharmony_ci<h3 id="description2">description</h3>
1981cb0ef41Sopenharmony_ci<p>Put a description in it.  It's a string.  This helps people discover your
1991cb0ef41Sopenharmony_cipackage, as it's listed in <code>npm search</code>.</p>
2001cb0ef41Sopenharmony_ci<h3 id="keywords">keywords</h3>
2011cb0ef41Sopenharmony_ci<p>Put keywords in it.  It's an array of strings.  This helps people discover
2021cb0ef41Sopenharmony_ciyour package as it's listed in <code>npm search</code>.</p>
2031cb0ef41Sopenharmony_ci<h3 id="homepage">homepage</h3>
2041cb0ef41Sopenharmony_ci<p>The url to the project homepage.</p>
2051cb0ef41Sopenharmony_ci<p>Example:</p>
2061cb0ef41Sopenharmony_ci<pre><code class="language-json">"homepage": "https://github.com/owner/project#readme"
2071cb0ef41Sopenharmony_ci</code></pre>
2081cb0ef41Sopenharmony_ci<h3 id="bugs">bugs</h3>
2091cb0ef41Sopenharmony_ci<p>The url to your project's issue tracker and / or the email address to which
2101cb0ef41Sopenharmony_ciissues should be reported. These are helpful for people who encounter
2111cb0ef41Sopenharmony_ciissues with your package.</p>
2121cb0ef41Sopenharmony_ci<p>It should look like this:</p>
2131cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2141cb0ef41Sopenharmony_ci  "bugs": {
2151cb0ef41Sopenharmony_ci    "url": "https://github.com/owner/project/issues",
2161cb0ef41Sopenharmony_ci    "email": "project@hostname.com"
2171cb0ef41Sopenharmony_ci  }
2181cb0ef41Sopenharmony_ci}
2191cb0ef41Sopenharmony_ci</code></pre>
2201cb0ef41Sopenharmony_ci<p>You can specify either one or both values. If you want to provide only a
2211cb0ef41Sopenharmony_ciurl, you can specify the value for "bugs" as a simple string instead of an
2221cb0ef41Sopenharmony_ciobject.</p>
2231cb0ef41Sopenharmony_ci<p>If a url is provided, it will be used by the <code>npm bugs</code> command.</p>
2241cb0ef41Sopenharmony_ci<h3 id="license">license</h3>
2251cb0ef41Sopenharmony_ci<p>You should specify a license for your package so that people know how they
2261cb0ef41Sopenharmony_ciare permitted to use it, and any restrictions you're placing on it.</p>
2271cb0ef41Sopenharmony_ci<p>If you're using a common license such as BSD-2-Clause or MIT, add a current
2281cb0ef41Sopenharmony_ciSPDX license identifier for the license you're using, like this:</p>
2291cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2301cb0ef41Sopenharmony_ci  "license" : "BSD-3-Clause"
2311cb0ef41Sopenharmony_ci}
2321cb0ef41Sopenharmony_ci</code></pre>
2331cb0ef41Sopenharmony_ci<p>You can check <a href="https://spdx.org/licenses/">the full list of SPDX license
2341cb0ef41Sopenharmony_ciIDs</a>.  Ideally you should pick one that is
2351cb0ef41Sopenharmony_ci<a href="https://opensource.org/licenses/">OSI</a> approved.</p>
2361cb0ef41Sopenharmony_ci<p>If your package is licensed under multiple common licenses, use an <a href="https://spdx.dev/specifications/">SPDX
2371cb0ef41Sopenharmony_cilicense expression syntax version 2.0
2381cb0ef41Sopenharmony_cistring</a>, like this:</p>
2391cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2401cb0ef41Sopenharmony_ci  "license" : "(ISC OR GPL-3.0)"
2411cb0ef41Sopenharmony_ci}
2421cb0ef41Sopenharmony_ci</code></pre>
2431cb0ef41Sopenharmony_ci<p>If you are using a license that hasn't been assigned an SPDX identifier, or if
2441cb0ef41Sopenharmony_ciyou are using a custom license, use a string value like this one:</p>
2451cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2461cb0ef41Sopenharmony_ci  "license" : "SEE LICENSE IN &lt;filename&gt;"
2471cb0ef41Sopenharmony_ci}
2481cb0ef41Sopenharmony_ci</code></pre>
2491cb0ef41Sopenharmony_ci<p>Then include a file named <code>&lt;filename&gt;</code> at the top level of the package.</p>
2501cb0ef41Sopenharmony_ci<p>Some old packages used license objects or a "licenses" property containing
2511cb0ef41Sopenharmony_cian array of license objects:</p>
2521cb0ef41Sopenharmony_ci<pre><code class="language-json">// Not valid metadata
2531cb0ef41Sopenharmony_ci{
2541cb0ef41Sopenharmony_ci  "license" : {
2551cb0ef41Sopenharmony_ci    "type" : "ISC",
2561cb0ef41Sopenharmony_ci    "url" : "https://opensource.org/licenses/ISC"
2571cb0ef41Sopenharmony_ci  }
2581cb0ef41Sopenharmony_ci}
2591cb0ef41Sopenharmony_ci
2601cb0ef41Sopenharmony_ci// Not valid metadata
2611cb0ef41Sopenharmony_ci{
2621cb0ef41Sopenharmony_ci  "licenses" : [
2631cb0ef41Sopenharmony_ci    {
2641cb0ef41Sopenharmony_ci      "type": "MIT",
2651cb0ef41Sopenharmony_ci      "url": "https://www.opensource.org/licenses/mit-license.php"
2661cb0ef41Sopenharmony_ci    },
2671cb0ef41Sopenharmony_ci    {
2681cb0ef41Sopenharmony_ci      "type": "Apache-2.0",
2691cb0ef41Sopenharmony_ci      "url": "https://opensource.org/licenses/apache2.0.php"
2701cb0ef41Sopenharmony_ci    }
2711cb0ef41Sopenharmony_ci  ]
2721cb0ef41Sopenharmony_ci}
2731cb0ef41Sopenharmony_ci</code></pre>
2741cb0ef41Sopenharmony_ci<p>Those styles are now deprecated. Instead, use SPDX expressions, like this:</p>
2751cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2761cb0ef41Sopenharmony_ci  "license": "ISC"
2771cb0ef41Sopenharmony_ci}
2781cb0ef41Sopenharmony_ci</code></pre>
2791cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2801cb0ef41Sopenharmony_ci  "license": "(MIT OR Apache-2.0)"
2811cb0ef41Sopenharmony_ci}
2821cb0ef41Sopenharmony_ci</code></pre>
2831cb0ef41Sopenharmony_ci<p>Finally, if you do not wish to grant others the right to use a private or
2841cb0ef41Sopenharmony_ciunpublished package under any terms:</p>
2851cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2861cb0ef41Sopenharmony_ci  "license": "UNLICENSED"
2871cb0ef41Sopenharmony_ci}
2881cb0ef41Sopenharmony_ci</code></pre>
2891cb0ef41Sopenharmony_ci<p>Consider also setting <code>"private": true</code> to prevent accidental publication.</p>
2901cb0ef41Sopenharmony_ci<h3 id="people-fields-author-contributors">people fields: author, contributors</h3>
2911cb0ef41Sopenharmony_ci<p>The "author" is one person.  "contributors" is an array of people.  A
2921cb0ef41Sopenharmony_ci"person" is an object with a "name" field and optionally "url" and "email",
2931cb0ef41Sopenharmony_cilike this:</p>
2941cb0ef41Sopenharmony_ci<pre><code class="language-json">{
2951cb0ef41Sopenharmony_ci  "name" : "Barney Rubble",
2961cb0ef41Sopenharmony_ci  "email" : "b@rubble.com",
2971cb0ef41Sopenharmony_ci  "url" : "http://barnyrubble.tumblr.com/"
2981cb0ef41Sopenharmony_ci}
2991cb0ef41Sopenharmony_ci</code></pre>
3001cb0ef41Sopenharmony_ci<p>Or you can shorten that all into a single string, and npm will parse it for
3011cb0ef41Sopenharmony_ciyou:</p>
3021cb0ef41Sopenharmony_ci<pre><code class="language-json">{
3031cb0ef41Sopenharmony_ci  "author": "Barney Rubble &lt;b@rubble.com&gt; (http://barnyrubble.tumblr.com/)"
3041cb0ef41Sopenharmony_ci}
3051cb0ef41Sopenharmony_ci</code></pre>
3061cb0ef41Sopenharmony_ci<p>Both email and url are optional either way.</p>
3071cb0ef41Sopenharmony_ci<p>npm also sets a top-level "maintainers" field with your npm user info.</p>
3081cb0ef41Sopenharmony_ci<h3 id="funding">funding</h3>
3091cb0ef41Sopenharmony_ci<p>You can specify an object containing a URL that provides up-to-date
3101cb0ef41Sopenharmony_ciinformation about ways to help fund development of your package, or a
3111cb0ef41Sopenharmony_cistring URL, or an array of these:</p>
3121cb0ef41Sopenharmony_ci<pre><code class="language-json">{
3131cb0ef41Sopenharmony_ci  "funding": {
3141cb0ef41Sopenharmony_ci    "type" : "individual",
3151cb0ef41Sopenharmony_ci    "url" : "http://example.com/donate"
3161cb0ef41Sopenharmony_ci  },
3171cb0ef41Sopenharmony_ci
3181cb0ef41Sopenharmony_ci  "funding": {
3191cb0ef41Sopenharmony_ci    "type" : "patreon",
3201cb0ef41Sopenharmony_ci    "url" : "https://www.patreon.com/my-account"
3211cb0ef41Sopenharmony_ci  },
3221cb0ef41Sopenharmony_ci
3231cb0ef41Sopenharmony_ci  "funding": "http://example.com/donate",
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_ci  "funding": [
3261cb0ef41Sopenharmony_ci    {
3271cb0ef41Sopenharmony_ci      "type" : "individual",
3281cb0ef41Sopenharmony_ci      "url" : "http://example.com/donate"
3291cb0ef41Sopenharmony_ci    },
3301cb0ef41Sopenharmony_ci    "http://example.com/donateAlso",
3311cb0ef41Sopenharmony_ci    {
3321cb0ef41Sopenharmony_ci      "type" : "patreon",
3331cb0ef41Sopenharmony_ci      "url" : "https://www.patreon.com/my-account"
3341cb0ef41Sopenharmony_ci    }
3351cb0ef41Sopenharmony_ci  ]
3361cb0ef41Sopenharmony_ci}
3371cb0ef41Sopenharmony_ci</code></pre>
3381cb0ef41Sopenharmony_ci<p>Users can use the <code>npm fund</code> subcommand to list the <code>funding</code> URLs of all
3391cb0ef41Sopenharmony_cidependencies of their project, direct and indirect. A shortcut to visit
3401cb0ef41Sopenharmony_cieach funding url is also available when providing the project name such as:
3411cb0ef41Sopenharmony_ci<code>npm fund &lt;projectname&gt;</code> (when there are multiple URLs, the first one will
3421cb0ef41Sopenharmony_cibe visited)</p>
3431cb0ef41Sopenharmony_ci<h3 id="files">files</h3>
3441cb0ef41Sopenharmony_ci<p>The optional <code>files</code> field is an array of file patterns that describes the
3451cb0ef41Sopenharmony_cientries to be included when your package is installed as a dependency. File
3461cb0ef41Sopenharmony_cipatterns follow a similar syntax to <code>.gitignore</code>, but reversed: including a
3471cb0ef41Sopenharmony_cifile, directory, or glob pattern (<code>*</code>, <code>**/*</code>, and such) will make it so
3481cb0ef41Sopenharmony_cithat file is included in the tarball when it's packed. Omitting the field
3491cb0ef41Sopenharmony_ciwill make it default to <code>["*"]</code>, which means it will include all files.</p>
3501cb0ef41Sopenharmony_ci<p>Some special files and directories are also included or excluded regardless
3511cb0ef41Sopenharmony_ciof whether they exist in the <code>files</code> array (see below).</p>
3521cb0ef41Sopenharmony_ci<p>You can also provide a <code>.npmignore</code> file in the root of your package or in
3531cb0ef41Sopenharmony_cisubdirectories, which will keep files from being included. At the root of
3541cb0ef41Sopenharmony_ciyour package it will not override the "files" field, but in subdirectories
3551cb0ef41Sopenharmony_ciit will. The <code>.npmignore</code> file works just like a <code>.gitignore</code>. If there is
3561cb0ef41Sopenharmony_cia <code>.gitignore</code> file, and <code>.npmignore</code> is missing, <code>.gitignore</code>'s contents
3571cb0ef41Sopenharmony_ciwill be used instead.</p>
3581cb0ef41Sopenharmony_ci<p>Certain files are always included, regardless of settings:</p>
3591cb0ef41Sopenharmony_ci<ul>
3601cb0ef41Sopenharmony_ci<li><code>package.json</code></li>
3611cb0ef41Sopenharmony_ci<li><code>README</code></li>
3621cb0ef41Sopenharmony_ci<li><code>LICENSE</code> / <code>LICENCE</code></li>
3631cb0ef41Sopenharmony_ci<li>The file in the "main" field</li>
3641cb0ef41Sopenharmony_ci<li>The file(s) in the "bin" field</li>
3651cb0ef41Sopenharmony_ci</ul>
3661cb0ef41Sopenharmony_ci<p><code>README</code> &amp; <code>LICENSE</code> can have any case and extension.</p>
3671cb0ef41Sopenharmony_ci<p>Some files are always ignored by default:</p>
3681cb0ef41Sopenharmony_ci<ul>
3691cb0ef41Sopenharmony_ci<li><code>*.orig</code></li>
3701cb0ef41Sopenharmony_ci<li><code>.*.swp</code></li>
3711cb0ef41Sopenharmony_ci<li><code>.DS_Store</code></li>
3721cb0ef41Sopenharmony_ci<li><code>._*</code></li>
3731cb0ef41Sopenharmony_ci<li><code>.git</code></li>
3741cb0ef41Sopenharmony_ci<li><code>.hg</code></li>
3751cb0ef41Sopenharmony_ci<li><code>.lock-wscript</code></li>
3761cb0ef41Sopenharmony_ci<li><code>.npmrc</code></li>
3771cb0ef41Sopenharmony_ci<li><code>.svn</code></li>
3781cb0ef41Sopenharmony_ci<li><code>.wafpickle-N</code></li>
3791cb0ef41Sopenharmony_ci<li><code>CVS</code></li>
3801cb0ef41Sopenharmony_ci<li><code>config.gypi</code></li>
3811cb0ef41Sopenharmony_ci<li><code>node_modules</code></li>
3821cb0ef41Sopenharmony_ci<li><code>npm-debug.log</code></li>
3831cb0ef41Sopenharmony_ci<li><code>package-lock.json</code> (use
3841cb0ef41Sopenharmony_ci<a href="../configuring-npm/npm-shrinkwrap-json.html"><code>npm-shrinkwrap.json</code></a>
3851cb0ef41Sopenharmony_ciif you wish it to be published)</li>
3861cb0ef41Sopenharmony_ci<li><code>pnpm-lock.yaml</code></li>
3871cb0ef41Sopenharmony_ci<li><code>yarn.lock</code></li>
3881cb0ef41Sopenharmony_ci</ul>
3891cb0ef41Sopenharmony_ci<p>Most of these ignored files can be included specifically if included in
3901cb0ef41Sopenharmony_cithe <code>files</code> globs.  Exceptions to this are:</p>
3911cb0ef41Sopenharmony_ci<ul>
3921cb0ef41Sopenharmony_ci<li><code>.git</code></li>
3931cb0ef41Sopenharmony_ci<li><code>.npmrc</code></li>
3941cb0ef41Sopenharmony_ci<li><code>node_modules</code></li>
3951cb0ef41Sopenharmony_ci<li><code>package-lock.json</code></li>
3961cb0ef41Sopenharmony_ci<li><code>pnpm-lock.yaml</code></li>
3971cb0ef41Sopenharmony_ci<li><code>yarn.lock</code></li>
3981cb0ef41Sopenharmony_ci</ul>
3991cb0ef41Sopenharmony_ci<p>These can not be included.</p>
4001cb0ef41Sopenharmony_ci<h3 id="main">main</h3>
4011cb0ef41Sopenharmony_ci<p>The main field is a module ID that is the primary entry point to your
4021cb0ef41Sopenharmony_ciprogram.  That is, if your package is named <code>foo</code>, and a user installs it,
4031cb0ef41Sopenharmony_ciand then does <code>require("foo")</code>, then your main module's exports object will
4041cb0ef41Sopenharmony_cibe returned.</p>
4051cb0ef41Sopenharmony_ci<p>This should be a module relative to the root of your package folder.</p>
4061cb0ef41Sopenharmony_ci<p>For most modules, it makes the most sense to have a main script and often
4071cb0ef41Sopenharmony_cinot much else.</p>
4081cb0ef41Sopenharmony_ci<p>If <code>main</code> is not set, it defaults to <code>index.js</code> in the package's root folder.</p>
4091cb0ef41Sopenharmony_ci<h3 id="browser">browser</h3>
4101cb0ef41Sopenharmony_ci<p>If your module is meant to be used client-side the browser field should be
4111cb0ef41Sopenharmony_ciused instead of the main field. This is helpful to hint users that it might
4121cb0ef41Sopenharmony_cirely on primitives that aren't available in Node.js modules. (e.g.
4131cb0ef41Sopenharmony_ci<code>window</code>)</p>
4141cb0ef41Sopenharmony_ci<h3 id="bin">bin</h3>
4151cb0ef41Sopenharmony_ci<p>A lot of packages have one or more executable files that they'd like to
4161cb0ef41Sopenharmony_ciinstall into the PATH. npm makes this pretty easy (in fact, it uses this
4171cb0ef41Sopenharmony_cifeature to install the "npm" executable.)</p>
4181cb0ef41Sopenharmony_ci<p>To use this, supply a <code>bin</code> field in your package.json which is a map of
4191cb0ef41Sopenharmony_cicommand name to local file name. When this package is installed globally,
4201cb0ef41Sopenharmony_cithat file will be either linked inside the global bins directory or
4211cb0ef41Sopenharmony_cia cmd (Windows Command File) will be created which executes the specified
4221cb0ef41Sopenharmony_cifile in the <code>bin</code> field, so it is available to run by <code>name</code> or <code>name.cmd</code> (on
4231cb0ef41Sopenharmony_ciWindows PowerShell). When this package is installed as a dependency in another
4241cb0ef41Sopenharmony_cipackage, the file will be linked where it will be available to that package
4251cb0ef41Sopenharmony_cieither directly by <code>npm exec</code> or by name in other scripts when invoking them
4261cb0ef41Sopenharmony_civia <code>npm run-script</code>.</p>
4271cb0ef41Sopenharmony_ci<p>For example, myapp could have this:</p>
4281cb0ef41Sopenharmony_ci<pre><code class="language-json">{
4291cb0ef41Sopenharmony_ci  "bin": {
4301cb0ef41Sopenharmony_ci    "myapp": "./cli.js"
4311cb0ef41Sopenharmony_ci  }
4321cb0ef41Sopenharmony_ci}
4331cb0ef41Sopenharmony_ci</code></pre>
4341cb0ef41Sopenharmony_ci<p>So, when you install myapp, in case of unix-like OS it'll create a symlink
4351cb0ef41Sopenharmony_cifrom the <code>cli.js</code> script to <code>/usr/local/bin/myapp</code> and in case of windows it
4361cb0ef41Sopenharmony_ciwill create a cmd file usually at <code>C:\Users\{Username}\AppData\Roaming\npm\myapp.cmd</code>
4371cb0ef41Sopenharmony_ciwhich runs the <code>cli.js</code> script.</p>
4381cb0ef41Sopenharmony_ci<p>If you have a single executable, and its name should be the name of the
4391cb0ef41Sopenharmony_cipackage, then you can just supply it as a string.  For example:</p>
4401cb0ef41Sopenharmony_ci<pre><code class="language-json">{
4411cb0ef41Sopenharmony_ci  "name": "my-program",
4421cb0ef41Sopenharmony_ci  "version": "1.2.5",
4431cb0ef41Sopenharmony_ci  "bin": "./path/to/program"
4441cb0ef41Sopenharmony_ci}
4451cb0ef41Sopenharmony_ci</code></pre>
4461cb0ef41Sopenharmony_ci<p>would be the same as this:</p>
4471cb0ef41Sopenharmony_ci<pre><code class="language-json">{
4481cb0ef41Sopenharmony_ci  "name": "my-program",
4491cb0ef41Sopenharmony_ci  "version": "1.2.5",
4501cb0ef41Sopenharmony_ci  "bin": {
4511cb0ef41Sopenharmony_ci    "my-program": "./path/to/program"
4521cb0ef41Sopenharmony_ci  }
4531cb0ef41Sopenharmony_ci}
4541cb0ef41Sopenharmony_ci</code></pre>
4551cb0ef41Sopenharmony_ci<p>Please make sure that your file(s) referenced in <code>bin</code> starts with
4561cb0ef41Sopenharmony_ci<code>#!/usr/bin/env node</code>, otherwise the scripts are started without the node
4571cb0ef41Sopenharmony_ciexecutable!</p>
4581cb0ef41Sopenharmony_ci<p>Note that you can also set the executable files using <a href="#directoriesbin">directories.bin</a>.</p>
4591cb0ef41Sopenharmony_ci<p>See <a href="../configuring-npm/folders#executables.html">folders</a> for more info on
4601cb0ef41Sopenharmony_ciexecutables.</p>
4611cb0ef41Sopenharmony_ci<h3 id="man">man</h3>
4621cb0ef41Sopenharmony_ci<p>Specify either a single file or an array of filenames to put in place for
4631cb0ef41Sopenharmony_cithe <code>man</code> program to find.</p>
4641cb0ef41Sopenharmony_ci<p>If only a single file is provided, then it's installed such that it is the
4651cb0ef41Sopenharmony_ciresult from <code>man &lt;pkgname&gt;</code>, regardless of its actual filename.  For
4661cb0ef41Sopenharmony_ciexample:</p>
4671cb0ef41Sopenharmony_ci<pre><code class="language-json">{
4681cb0ef41Sopenharmony_ci  "name": "foo",
4691cb0ef41Sopenharmony_ci  "version": "1.2.3",
4701cb0ef41Sopenharmony_ci  "description": "A packaged foo fooer for fooing foos",
4711cb0ef41Sopenharmony_ci  "main": "foo.js",
4721cb0ef41Sopenharmony_ci  "man": "./man/doc.1"
4731cb0ef41Sopenharmony_ci}
4741cb0ef41Sopenharmony_ci</code></pre>
4751cb0ef41Sopenharmony_ci<p>would link the <code>./man/doc.1</code> file in such that it is the target for <code>man foo</code></p>
4761cb0ef41Sopenharmony_ci<p>If the filename doesn't start with the package name, then it's prefixed.
4771cb0ef41Sopenharmony_ciSo, this:</p>
4781cb0ef41Sopenharmony_ci<pre><code class="language-json">{
4791cb0ef41Sopenharmony_ci  "name": "foo",
4801cb0ef41Sopenharmony_ci  "version": "1.2.3",
4811cb0ef41Sopenharmony_ci  "description": "A packaged foo fooer for fooing foos",
4821cb0ef41Sopenharmony_ci  "main": "foo.js",
4831cb0ef41Sopenharmony_ci  "man": [
4841cb0ef41Sopenharmony_ci    "./man/foo.1",
4851cb0ef41Sopenharmony_ci    "./man/bar.1"
4861cb0ef41Sopenharmony_ci  ]
4871cb0ef41Sopenharmony_ci}
4881cb0ef41Sopenharmony_ci</code></pre>
4891cb0ef41Sopenharmony_ci<p>will create files to do <code>man foo</code> and <code>man foo-bar</code>.</p>
4901cb0ef41Sopenharmony_ci<p>Man files must end with a number, and optionally a <code>.gz</code> suffix if they are
4911cb0ef41Sopenharmony_cicompressed.  The number dictates which man section the file is installed
4921cb0ef41Sopenharmony_ciinto.</p>
4931cb0ef41Sopenharmony_ci<pre><code class="language-json">{
4941cb0ef41Sopenharmony_ci  "name": "foo",
4951cb0ef41Sopenharmony_ci  "version": "1.2.3",
4961cb0ef41Sopenharmony_ci  "description": "A packaged foo fooer for fooing foos",
4971cb0ef41Sopenharmony_ci  "main": "foo.js",
4981cb0ef41Sopenharmony_ci  "man": [
4991cb0ef41Sopenharmony_ci    "./man/foo.1",
5001cb0ef41Sopenharmony_ci    "./man/foo.2"
5011cb0ef41Sopenharmony_ci  ]
5021cb0ef41Sopenharmony_ci}
5031cb0ef41Sopenharmony_ci</code></pre>
5041cb0ef41Sopenharmony_ci<p>will create entries for <code>man foo</code> and <code>man 2 foo</code></p>
5051cb0ef41Sopenharmony_ci<h3 id="directories">directories</h3>
5061cb0ef41Sopenharmony_ci<p>The CommonJS <a href="http://wiki.commonjs.org/wiki/Packages/1.0">Packages</a> spec
5071cb0ef41Sopenharmony_cidetails a few ways that you can indicate the structure of your package
5081cb0ef41Sopenharmony_ciusing a <code>directories</code> object. If you look at <a href="https://registry.npmjs.org/npm/latest">npm's
5091cb0ef41Sopenharmony_cipackage.json</a>, you'll see that it
5101cb0ef41Sopenharmony_cihas directories for doc, lib, and man.</p>
5111cb0ef41Sopenharmony_ci<p>In the future, this information may be used in other creative ways.</p>
5121cb0ef41Sopenharmony_ci<h4 id="directoriesbin">directories.bin</h4>
5131cb0ef41Sopenharmony_ci<p>If you specify a <code>bin</code> directory in <code>directories.bin</code>, all the files in
5141cb0ef41Sopenharmony_cithat folder will be added.</p>
5151cb0ef41Sopenharmony_ci<p>Because of the way the <code>bin</code> directive works, specifying both a <code>bin</code> path
5161cb0ef41Sopenharmony_ciand setting <code>directories.bin</code> is an error. If you want to specify
5171cb0ef41Sopenharmony_ciindividual files, use <code>bin</code>, and for all the files in an existing <code>bin</code>
5181cb0ef41Sopenharmony_cidirectory, use <code>directories.bin</code>.</p>
5191cb0ef41Sopenharmony_ci<h4 id="directoriesman">directories.man</h4>
5201cb0ef41Sopenharmony_ci<p>A folder that is full of man pages.  Sugar to generate a "man" array by
5211cb0ef41Sopenharmony_ciwalking the folder.</p>
5221cb0ef41Sopenharmony_ci<h3 id="repository">repository</h3>
5231cb0ef41Sopenharmony_ci<p>Specify the place where your code lives. This is helpful for people who
5241cb0ef41Sopenharmony_ciwant to contribute.  If the git repo is on GitHub, then the <code>npm docs</code>
5251cb0ef41Sopenharmony_cicommand will be able to find you.</p>
5261cb0ef41Sopenharmony_ci<p>Do it like this:</p>
5271cb0ef41Sopenharmony_ci<pre><code class="language-json">{
5281cb0ef41Sopenharmony_ci  "repository": {
5291cb0ef41Sopenharmony_ci    "type": "git",
5301cb0ef41Sopenharmony_ci    "url": "https://github.com/npm/cli.git"
5311cb0ef41Sopenharmony_ci  }
5321cb0ef41Sopenharmony_ci}
5331cb0ef41Sopenharmony_ci</code></pre>
5341cb0ef41Sopenharmony_ci<p>The URL should be a publicly available (perhaps read-only) url that can be
5351cb0ef41Sopenharmony_cihanded directly to a VCS program without any modification.  It should not
5361cb0ef41Sopenharmony_cibe a url to an html project page that you put in your browser.  It's for
5371cb0ef41Sopenharmony_cicomputers.</p>
5381cb0ef41Sopenharmony_ci<p>For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the
5391cb0ef41Sopenharmony_cisame shortcut syntax you use for <code>npm install</code>:</p>
5401cb0ef41Sopenharmony_ci<pre><code class="language-json">{
5411cb0ef41Sopenharmony_ci  "repository": "npm/npm",
5421cb0ef41Sopenharmony_ci
5431cb0ef41Sopenharmony_ci  "repository": "github:user/repo",
5441cb0ef41Sopenharmony_ci
5451cb0ef41Sopenharmony_ci  "repository": "gist:11081aaa281",
5461cb0ef41Sopenharmony_ci
5471cb0ef41Sopenharmony_ci  "repository": "bitbucket:user/repo",
5481cb0ef41Sopenharmony_ci
5491cb0ef41Sopenharmony_ci  "repository": "gitlab:user/repo"
5501cb0ef41Sopenharmony_ci}
5511cb0ef41Sopenharmony_ci</code></pre>
5521cb0ef41Sopenharmony_ci<p>If the <code>package.json</code> for your package is not in the root directory (for
5531cb0ef41Sopenharmony_ciexample if it is part of a monorepo), you can specify the directory in
5541cb0ef41Sopenharmony_ciwhich it lives:</p>
5551cb0ef41Sopenharmony_ci<pre><code class="language-json">{
5561cb0ef41Sopenharmony_ci  "repository": {
5571cb0ef41Sopenharmony_ci    "type": "git",
5581cb0ef41Sopenharmony_ci    "url": "https://github.com/facebook/react.git",
5591cb0ef41Sopenharmony_ci    "directory": "packages/react-dom"
5601cb0ef41Sopenharmony_ci  }
5611cb0ef41Sopenharmony_ci}
5621cb0ef41Sopenharmony_ci</code></pre>
5631cb0ef41Sopenharmony_ci<h3 id="scripts">scripts</h3>
5641cb0ef41Sopenharmony_ci<p>The "scripts" property is a dictionary containing script commands that are
5651cb0ef41Sopenharmony_cirun at various times in the lifecycle of your package.  The key is the
5661cb0ef41Sopenharmony_cilifecycle event, and the value is the command to run at that point.</p>
5671cb0ef41Sopenharmony_ci<p>See <a href="../using-npm/scripts.html"><code>scripts</code></a> to find out more about writing package
5681cb0ef41Sopenharmony_ciscripts.</p>
5691cb0ef41Sopenharmony_ci<h3 id="config">config</h3>
5701cb0ef41Sopenharmony_ci<p>A "config" object can be used to set configuration parameters used in
5711cb0ef41Sopenharmony_cipackage scripts that persist across upgrades.  For instance, if a package
5721cb0ef41Sopenharmony_cihad the following:</p>
5731cb0ef41Sopenharmony_ci<pre><code class="language-json">{
5741cb0ef41Sopenharmony_ci  "name": "foo",
5751cb0ef41Sopenharmony_ci  "config": {
5761cb0ef41Sopenharmony_ci    "port": "8080"
5771cb0ef41Sopenharmony_ci  }
5781cb0ef41Sopenharmony_ci}
5791cb0ef41Sopenharmony_ci</code></pre>
5801cb0ef41Sopenharmony_ci<p>It could also have a "start" command that referenced the
5811cb0ef41Sopenharmony_ci<code>npm_package_config_port</code> environment variable.</p>
5821cb0ef41Sopenharmony_ci<h3 id="dependencies">dependencies</h3>
5831cb0ef41Sopenharmony_ci<p>Dependencies are specified in a simple object that maps a package name to a
5841cb0ef41Sopenharmony_civersion range. The version range is a string which has one or more
5851cb0ef41Sopenharmony_cispace-separated descriptors.  Dependencies can also be identified with a
5861cb0ef41Sopenharmony_citarball or git URL.</p>
5871cb0ef41Sopenharmony_ci<p><strong>Please do not put test harnesses or transpilers or other "development"
5881cb0ef41Sopenharmony_citime tools in your <code>dependencies</code> object.</strong>  See <code>devDependencies</code>, below.</p>
5891cb0ef41Sopenharmony_ci<p>See <a href="https://github.com/npm/node-semver#versions">semver</a> for more details about specifying version ranges.</p>
5901cb0ef41Sopenharmony_ci<ul>
5911cb0ef41Sopenharmony_ci<li><code>version</code> Must match <code>version</code> exactly</li>
5921cb0ef41Sopenharmony_ci<li><code>&gt;version</code> Must be greater than <code>version</code></li>
5931cb0ef41Sopenharmony_ci<li><code>&gt;=version</code> etc</li>
5941cb0ef41Sopenharmony_ci<li><code>&lt;version</code></li>
5951cb0ef41Sopenharmony_ci<li><code>&lt;=version</code></li>
5961cb0ef41Sopenharmony_ci<li><code>~version</code> "Approximately equivalent to version"  See
5971cb0ef41Sopenharmony_ci<a href="https://github.com/npm/node-semver#versions">semver</a></li>
5981cb0ef41Sopenharmony_ci<li><code>^version</code> "Compatible with version"  See <a href="https://github.com/npm/node-semver#versions">semver</a></li>
5991cb0ef41Sopenharmony_ci<li><code>1.2.x</code> 1.2.0, 1.2.1, etc., but not 1.3.0</li>
6001cb0ef41Sopenharmony_ci<li><code>http://...</code> See 'URLs as Dependencies' below</li>
6011cb0ef41Sopenharmony_ci<li><code>*</code> Matches any version</li>
6021cb0ef41Sopenharmony_ci<li><code>""</code> (just an empty string) Same as <code>*</code></li>
6031cb0ef41Sopenharmony_ci<li><code>version1 - version2</code> Same as <code>&gt;=version1 &lt;=version2</code>.</li>
6041cb0ef41Sopenharmony_ci<li><code>range1 || range2</code> Passes if either range1 or range2 are satisfied.</li>
6051cb0ef41Sopenharmony_ci<li><code>git...</code> See 'Git URLs as Dependencies' below</li>
6061cb0ef41Sopenharmony_ci<li><code>user/repo</code> See 'GitHub URLs' below</li>
6071cb0ef41Sopenharmony_ci<li><code>tag</code> A specific version tagged and published as <code>tag</code>  See <a href="../commands/npm-dist-tag.html"><code>npm dist-tag</code></a></li>
6081cb0ef41Sopenharmony_ci<li><code>path/path/path</code> See <a href="#local-paths">Local Paths</a> below</li>
6091cb0ef41Sopenharmony_ci</ul>
6101cb0ef41Sopenharmony_ci<p>For example, these are all valid:</p>
6111cb0ef41Sopenharmony_ci<pre><code class="language-json">{
6121cb0ef41Sopenharmony_ci  "dependencies": {
6131cb0ef41Sopenharmony_ci    "foo": "1.0.0 - 2.9999.9999",
6141cb0ef41Sopenharmony_ci    "bar": "&gt;=1.0.2 &lt;2.1.2",
6151cb0ef41Sopenharmony_ci    "baz": "&gt;1.0.2 &lt;=2.3.4",
6161cb0ef41Sopenharmony_ci    "boo": "2.0.1",
6171cb0ef41Sopenharmony_ci    "qux": "&lt;1.0.0 || &gt;=2.3.1 &lt;2.4.5 || &gt;=2.5.2 &lt;3.0.0",
6181cb0ef41Sopenharmony_ci    "asd": "http://asdf.com/asdf.tar.gz",
6191cb0ef41Sopenharmony_ci    "til": "~1.2",
6201cb0ef41Sopenharmony_ci    "elf": "~1.2.3",
6211cb0ef41Sopenharmony_ci    "two": "2.x",
6221cb0ef41Sopenharmony_ci    "thr": "3.3.x",
6231cb0ef41Sopenharmony_ci    "lat": "latest",
6241cb0ef41Sopenharmony_ci    "dyl": "file:../dyl"
6251cb0ef41Sopenharmony_ci  }
6261cb0ef41Sopenharmony_ci}
6271cb0ef41Sopenharmony_ci</code></pre>
6281cb0ef41Sopenharmony_ci<h4 id="urls-as-dependencies">URLs as Dependencies</h4>
6291cb0ef41Sopenharmony_ci<p>You may specify a tarball URL in place of a version range.</p>
6301cb0ef41Sopenharmony_ci<p>This tarball will be downloaded and installed locally to your package at
6311cb0ef41Sopenharmony_ciinstall time.</p>
6321cb0ef41Sopenharmony_ci<h4 id="git-urls-as-dependencies">Git URLs as Dependencies</h4>
6331cb0ef41Sopenharmony_ci<p>Git urls are of the form:</p>
6341cb0ef41Sopenharmony_ci<pre><code class="language-bash">&lt;protocol&gt;://[&lt;user&gt;[:&lt;password&gt;]@]&lt;hostname&gt;[:&lt;port&gt;][:][/]&lt;path&gt;[#&lt;commit-ish&gt; | #semver:&lt;semver&gt;]
6351cb0ef41Sopenharmony_ci</code></pre>
6361cb0ef41Sopenharmony_ci<p><code>&lt;protocol&gt;</code> is one of <code>git</code>, <code>git+ssh</code>, <code>git+http</code>, <code>git+https</code>, or
6371cb0ef41Sopenharmony_ci<code>git+file</code>.</p>
6381cb0ef41Sopenharmony_ci<p>If <code>#&lt;commit-ish&gt;</code> is provided, it will be used to clone exactly that
6391cb0ef41Sopenharmony_cicommit. If the commit-ish has the format <code>#semver:&lt;semver&gt;</code>, <code>&lt;semver&gt;</code> can
6401cb0ef41Sopenharmony_cibe any valid semver range or exact version, and npm will look for any tags
6411cb0ef41Sopenharmony_cior refs matching that range in the remote repository, much as it would for
6421cb0ef41Sopenharmony_cia registry dependency. If neither <code>#&lt;commit-ish&gt;</code> or <code>#semver:&lt;semver&gt;</code> is
6431cb0ef41Sopenharmony_cispecified, then the default branch is used.</p>
6441cb0ef41Sopenharmony_ci<p>Examples:</p>
6451cb0ef41Sopenharmony_ci<pre><code class="language-bash">git+ssh://git@github.com:npm/cli.git#v1.0.27
6461cb0ef41Sopenharmony_cigit+ssh://git@github.com:npm/cli#semver:^5.0
6471cb0ef41Sopenharmony_cigit+https://isaacs@github.com/npm/cli.git
6481cb0ef41Sopenharmony_cigit://github.com/npm/cli.git#v1.0.27
6491cb0ef41Sopenharmony_ci</code></pre>
6501cb0ef41Sopenharmony_ci<p>When installing from a <code>git</code> repository, the presence of certain fields in the
6511cb0ef41Sopenharmony_ci<code>package.json</code> will cause npm to believe it needs to perform a build. To do so
6521cb0ef41Sopenharmony_ciyour repository will be cloned into a temporary directory, all of its deps
6531cb0ef41Sopenharmony_ciinstalled, relevant scripts run, and the resulting directory packed and
6541cb0ef41Sopenharmony_ciinstalled.</p>
6551cb0ef41Sopenharmony_ci<p>This flow will occur if your git dependency uses <code>workspaces</code>, or if any of the
6561cb0ef41Sopenharmony_cifollowing scripts are present:</p>
6571cb0ef41Sopenharmony_ci<ul>
6581cb0ef41Sopenharmony_ci<li><code>build</code></li>
6591cb0ef41Sopenharmony_ci<li><code>prepare</code></li>
6601cb0ef41Sopenharmony_ci<li><code>prepack</code></li>
6611cb0ef41Sopenharmony_ci<li><code>preinstall</code></li>
6621cb0ef41Sopenharmony_ci<li><code>install</code></li>
6631cb0ef41Sopenharmony_ci<li><code>postinstall</code></li>
6641cb0ef41Sopenharmony_ci</ul>
6651cb0ef41Sopenharmony_ci<p>If your git repository includes pre-built artifacts, you will likely want to
6661cb0ef41Sopenharmony_cimake sure that none of the above scripts are defined, or your dependency
6671cb0ef41Sopenharmony_ciwill be rebuilt for every installation.</p>
6681cb0ef41Sopenharmony_ci<h4 id="github-urls">GitHub URLs</h4>
6691cb0ef41Sopenharmony_ci<p>As of version 1.1.65, you can refer to GitHub urls as just "foo":
6701cb0ef41Sopenharmony_ci"user/foo-project".  Just as with git URLs, a <code>commit-ish</code> suffix can be
6711cb0ef41Sopenharmony_ciincluded.  For example:</p>
6721cb0ef41Sopenharmony_ci<pre><code class="language-json">{
6731cb0ef41Sopenharmony_ci  "name": "foo",
6741cb0ef41Sopenharmony_ci  "version": "0.0.0",
6751cb0ef41Sopenharmony_ci  "dependencies": {
6761cb0ef41Sopenharmony_ci    "express": "expressjs/express",
6771cb0ef41Sopenharmony_ci    "mocha": "mochajs/mocha#4727d357ea",
6781cb0ef41Sopenharmony_ci    "module": "user/repo#feature\/branch"
6791cb0ef41Sopenharmony_ci  }
6801cb0ef41Sopenharmony_ci}
6811cb0ef41Sopenharmony_ci</code></pre>
6821cb0ef41Sopenharmony_ci<h4 id="local-paths">Local Paths</h4>
6831cb0ef41Sopenharmony_ci<p>As of version 2.0.0 you can provide a path to a local directory that
6841cb0ef41Sopenharmony_cicontains a package. Local paths can be saved using <code>npm install -S</code> or <code>npm install --save</code>, using any of these forms:</p>
6851cb0ef41Sopenharmony_ci<pre><code class="language-bash">../foo/bar
6861cb0ef41Sopenharmony_ci~/foo/bar
6871cb0ef41Sopenharmony_ci./foo/bar
6881cb0ef41Sopenharmony_ci/foo/bar
6891cb0ef41Sopenharmony_ci</code></pre>
6901cb0ef41Sopenharmony_ci<p>in which case they will be normalized to a relative path and added to your
6911cb0ef41Sopenharmony_ci<code>package.json</code>. For example:</p>
6921cb0ef41Sopenharmony_ci<pre><code class="language-json">{
6931cb0ef41Sopenharmony_ci  "name": "baz",
6941cb0ef41Sopenharmony_ci  "dependencies": {
6951cb0ef41Sopenharmony_ci    "bar": "file:../foo/bar"
6961cb0ef41Sopenharmony_ci  }
6971cb0ef41Sopenharmony_ci}
6981cb0ef41Sopenharmony_ci</code></pre>
6991cb0ef41Sopenharmony_ci<p>This feature is helpful for local offline development and creating tests
7001cb0ef41Sopenharmony_cithat require npm installing where you don't want to hit an external server,
7011cb0ef41Sopenharmony_cibut should not be used when publishing your package to the public registry.</p>
7021cb0ef41Sopenharmony_ci<p><em>note</em>: Packages linked by local path will not have their own
7031cb0ef41Sopenharmony_cidependencies installed when <code>npm install</code> is ran in this case.  You must
7041cb0ef41Sopenharmony_cirun <code>npm install</code> from inside the local path itself.</p>
7051cb0ef41Sopenharmony_ci<h3 id="devdependencies">devDependencies</h3>
7061cb0ef41Sopenharmony_ci<p>If someone is planning on downloading and using your module in their
7071cb0ef41Sopenharmony_ciprogram, then they probably don't want or need to download and build the
7081cb0ef41Sopenharmony_ciexternal test or documentation framework that you use.</p>
7091cb0ef41Sopenharmony_ci<p>In this case, it's best to map these additional items in a
7101cb0ef41Sopenharmony_ci<code>devDependencies</code> object.</p>
7111cb0ef41Sopenharmony_ci<p>These things will be installed when doing <code>npm link</code> or <code>npm install</code> from
7121cb0ef41Sopenharmony_cithe root of a package, and can be managed like any other npm configuration
7131cb0ef41Sopenharmony_ciparam.  See <a href="../using-npm/config.html"><code>config</code></a> for more on the topic.</p>
7141cb0ef41Sopenharmony_ci<p>For build steps that are not platform-specific, such as compiling
7151cb0ef41Sopenharmony_ciCoffeeScript or other languages to JavaScript, use the <code>prepare</code> script to
7161cb0ef41Sopenharmony_cido this, and make the required package a devDependency.</p>
7171cb0ef41Sopenharmony_ci<p>For example:</p>
7181cb0ef41Sopenharmony_ci<pre><code class="language-json">{
7191cb0ef41Sopenharmony_ci  "name": "ethopia-waza",
7201cb0ef41Sopenharmony_ci  "description": "a delightfully fruity coffee varietal",
7211cb0ef41Sopenharmony_ci  "version": "1.2.3",
7221cb0ef41Sopenharmony_ci  "devDependencies": {
7231cb0ef41Sopenharmony_ci    "coffee-script": "~1.6.3"
7241cb0ef41Sopenharmony_ci  },
7251cb0ef41Sopenharmony_ci  "scripts": {
7261cb0ef41Sopenharmony_ci    "prepare": "coffee -o lib/ -c src/waza.coffee"
7271cb0ef41Sopenharmony_ci  },
7281cb0ef41Sopenharmony_ci  "main": "lib/waza.js"
7291cb0ef41Sopenharmony_ci}
7301cb0ef41Sopenharmony_ci</code></pre>
7311cb0ef41Sopenharmony_ci<p>The <code>prepare</code> script will be run before publishing, so that users can
7321cb0ef41Sopenharmony_ciconsume the functionality without requiring them to compile it themselves.
7331cb0ef41Sopenharmony_ciIn dev mode (ie, locally running <code>npm install</code>), it'll run this script as
7341cb0ef41Sopenharmony_ciwell, so that you can test it easily.</p>
7351cb0ef41Sopenharmony_ci<h3 id="peerdependencies">peerDependencies</h3>
7361cb0ef41Sopenharmony_ci<p>In some cases, you want to express the compatibility of your package with a
7371cb0ef41Sopenharmony_cihost tool or library, while not necessarily doing a <code>require</code> of this host.
7381cb0ef41Sopenharmony_ciThis is usually referred to as a <em>plugin</em>. Notably, your module may be
7391cb0ef41Sopenharmony_ciexposing a specific interface, expected and specified by the host
7401cb0ef41Sopenharmony_cidocumentation.</p>
7411cb0ef41Sopenharmony_ci<p>For example:</p>
7421cb0ef41Sopenharmony_ci<pre><code class="language-json">{
7431cb0ef41Sopenharmony_ci  "name": "tea-latte",
7441cb0ef41Sopenharmony_ci  "version": "1.3.5",
7451cb0ef41Sopenharmony_ci  "peerDependencies": {
7461cb0ef41Sopenharmony_ci    "tea": "2.x"
7471cb0ef41Sopenharmony_ci  }
7481cb0ef41Sopenharmony_ci}
7491cb0ef41Sopenharmony_ci</code></pre>
7501cb0ef41Sopenharmony_ci<p>This ensures your package <code>tea-latte</code> can be installed <em>along</em> with the
7511cb0ef41Sopenharmony_cisecond major version of the host package <code>tea</code> only. <code>npm install tea-latte</code> could possibly yield the following dependency graph:</p>
7521cb0ef41Sopenharmony_ci<pre><code class="language-bash">├── tea-latte@1.3.5
7531cb0ef41Sopenharmony_ci└── tea@2.2.0
7541cb0ef41Sopenharmony_ci</code></pre>
7551cb0ef41Sopenharmony_ci<p>In npm versions 3 through 6, <code>peerDependencies</code> were not automatically
7561cb0ef41Sopenharmony_ciinstalled, and would raise a warning if an invalid version of the peer
7571cb0ef41Sopenharmony_cidependency was found in the tree.  As of npm v7, peerDependencies <em>are</em>
7581cb0ef41Sopenharmony_ciinstalled by default.</p>
7591cb0ef41Sopenharmony_ci<p>Trying to install another plugin with a conflicting requirement may cause
7601cb0ef41Sopenharmony_cian error if the tree cannot be resolved correctly. For this reason, make
7611cb0ef41Sopenharmony_cisure your plugin requirement is as broad as possible, and not to lock it
7621cb0ef41Sopenharmony_cidown to specific patch versions.</p>
7631cb0ef41Sopenharmony_ci<p>Assuming the host complies with <a href="https://semver.org/">semver</a>, only changes
7641cb0ef41Sopenharmony_ciin the host package's major version will break your plugin. Thus, if you've
7651cb0ef41Sopenharmony_ciworked with every 1.x version of the host package, use <code>"^1.0"</code> or <code>"1.x"</code>
7661cb0ef41Sopenharmony_cito express this. If you depend on features introduced in 1.5.2, use
7671cb0ef41Sopenharmony_ci<code>"^1.5.2"</code>.</p>
7681cb0ef41Sopenharmony_ci<h3 id="peerdependenciesmeta">peerDependenciesMeta</h3>
7691cb0ef41Sopenharmony_ci<p>When a user installs your package, npm will emit warnings if packages
7701cb0ef41Sopenharmony_cispecified in <code>peerDependencies</code> are not already installed. The
7711cb0ef41Sopenharmony_ci<code>peerDependenciesMeta</code> field serves to provide npm more information on how
7721cb0ef41Sopenharmony_ciyour peer dependencies are to be used. Specifically, it allows peer
7731cb0ef41Sopenharmony_cidependencies to be marked as optional.</p>
7741cb0ef41Sopenharmony_ci<p>For example:</p>
7751cb0ef41Sopenharmony_ci<pre><code class="language-json">{
7761cb0ef41Sopenharmony_ci  "name": "tea-latte",
7771cb0ef41Sopenharmony_ci  "version": "1.3.5",
7781cb0ef41Sopenharmony_ci  "peerDependencies": {
7791cb0ef41Sopenharmony_ci    "tea": "2.x",
7801cb0ef41Sopenharmony_ci    "soy-milk": "1.2"
7811cb0ef41Sopenharmony_ci  },
7821cb0ef41Sopenharmony_ci  "peerDependenciesMeta": {
7831cb0ef41Sopenharmony_ci    "soy-milk": {
7841cb0ef41Sopenharmony_ci      "optional": true
7851cb0ef41Sopenharmony_ci    }
7861cb0ef41Sopenharmony_ci  }
7871cb0ef41Sopenharmony_ci}
7881cb0ef41Sopenharmony_ci</code></pre>
7891cb0ef41Sopenharmony_ci<p>Marking a peer dependency as optional ensures npm will not emit a warning
7901cb0ef41Sopenharmony_ciif the <code>soy-milk</code> package is not installed on the host. This allows you to
7911cb0ef41Sopenharmony_ciintegrate and interact with a variety of host packages without requiring
7921cb0ef41Sopenharmony_ciall of them to be installed.</p>
7931cb0ef41Sopenharmony_ci<h3 id="bundledependencies">bundleDependencies</h3>
7941cb0ef41Sopenharmony_ci<p>This defines an array of package names that will be bundled when publishing
7951cb0ef41Sopenharmony_cithe package.</p>
7961cb0ef41Sopenharmony_ci<p>In cases where you need to preserve npm packages locally or have them
7971cb0ef41Sopenharmony_ciavailable through a single file download, you can bundle the packages in a
7981cb0ef41Sopenharmony_citarball file by specifying the package names in the <code>bundleDependencies</code>
7991cb0ef41Sopenharmony_ciarray and executing <code>npm pack</code>.</p>
8001cb0ef41Sopenharmony_ci<p>For example:</p>
8011cb0ef41Sopenharmony_ci<p>If we define a package.json like this:</p>
8021cb0ef41Sopenharmony_ci<pre><code class="language-json">{
8031cb0ef41Sopenharmony_ci  "name": "awesome-web-framework",
8041cb0ef41Sopenharmony_ci  "version": "1.0.0",
8051cb0ef41Sopenharmony_ci  "bundleDependencies": [
8061cb0ef41Sopenharmony_ci    "renderized",
8071cb0ef41Sopenharmony_ci    "super-streams"
8081cb0ef41Sopenharmony_ci  ]
8091cb0ef41Sopenharmony_ci}
8101cb0ef41Sopenharmony_ci</code></pre>
8111cb0ef41Sopenharmony_ci<p>we can obtain <code>awesome-web-framework-1.0.0.tgz</code> file by running <code>npm pack</code>.
8121cb0ef41Sopenharmony_ciThis file contains the dependencies <code>renderized</code> and <code>super-streams</code> which
8131cb0ef41Sopenharmony_cican be installed in a new project by executing <code>npm install awesome-web-framework-1.0.0.tgz</code>.  Note that the package names do not
8141cb0ef41Sopenharmony_ciinclude any versions, as that information is specified in <code>dependencies</code>.</p>
8151cb0ef41Sopenharmony_ci<p>If this is spelled <code>"bundledDependencies"</code>, then that is also honored.</p>
8161cb0ef41Sopenharmony_ci<p>Alternatively, <code>"bundleDependencies"</code> can be defined as a boolean value. A
8171cb0ef41Sopenharmony_civalue of <code>true</code> will bundle all dependencies, a value of <code>false</code> will bundle
8181cb0ef41Sopenharmony_cinone.</p>
8191cb0ef41Sopenharmony_ci<h3 id="optionaldependencies">optionalDependencies</h3>
8201cb0ef41Sopenharmony_ci<p>If a dependency can be used, but you would like npm to proceed if it cannot
8211cb0ef41Sopenharmony_cibe found or fails to install, then you may put it in the
8221cb0ef41Sopenharmony_ci<code>optionalDependencies</code> object.  This is a map of package name to version or
8231cb0ef41Sopenharmony_ciurl, just like the <code>dependencies</code> object.  The difference is that build
8241cb0ef41Sopenharmony_cifailures do not cause installation to fail.  Running <code>npm install --omit=optional</code> will prevent these dependencies from being installed.</p>
8251cb0ef41Sopenharmony_ci<p>It is still your program's responsibility to handle the lack of the
8261cb0ef41Sopenharmony_cidependency.  For example, something like this:</p>
8271cb0ef41Sopenharmony_ci<pre><code class="language-js">try {
8281cb0ef41Sopenharmony_ci  var foo = require('foo')
8291cb0ef41Sopenharmony_ci  var fooVersion = require('foo/package.json').version
8301cb0ef41Sopenharmony_ci} catch (er) {
8311cb0ef41Sopenharmony_ci  foo = null
8321cb0ef41Sopenharmony_ci}
8331cb0ef41Sopenharmony_ciif ( notGoodFooVersion(fooVersion) ) {
8341cb0ef41Sopenharmony_ci  foo = null
8351cb0ef41Sopenharmony_ci}
8361cb0ef41Sopenharmony_ci
8371cb0ef41Sopenharmony_ci// .. then later in your program ..
8381cb0ef41Sopenharmony_ci
8391cb0ef41Sopenharmony_ciif (foo) {
8401cb0ef41Sopenharmony_ci  foo.doFooThings()
8411cb0ef41Sopenharmony_ci}
8421cb0ef41Sopenharmony_ci</code></pre>
8431cb0ef41Sopenharmony_ci<p>Entries in <code>optionalDependencies</code> will override entries of the same name in
8441cb0ef41Sopenharmony_ci<code>dependencies</code>, so it's usually best to only put in one place.</p>
8451cb0ef41Sopenharmony_ci<h3 id="overrides">overrides</h3>
8461cb0ef41Sopenharmony_ci<p>If you need to make specific changes to dependencies of your dependencies, for
8471cb0ef41Sopenharmony_ciexample replacing the version of a dependency with a known security issue,
8481cb0ef41Sopenharmony_cireplacing an existing dependency with a fork, or making sure that the same
8491cb0ef41Sopenharmony_civersion of a package is used everywhere, then you may add an override.</p>
8501cb0ef41Sopenharmony_ci<p>Overrides provide a way to replace a package in your dependency tree with
8511cb0ef41Sopenharmony_cianother version, or another package entirely. These changes can be scoped as
8521cb0ef41Sopenharmony_cispecific or as vague as desired.</p>
8531cb0ef41Sopenharmony_ci<p>To make sure the package <code>foo</code> is always installed as version <code>1.0.0</code> no matter
8541cb0ef41Sopenharmony_ciwhat version your dependencies rely on:</p>
8551cb0ef41Sopenharmony_ci<pre><code class="language-json">{
8561cb0ef41Sopenharmony_ci  "overrides": {
8571cb0ef41Sopenharmony_ci    "foo": "1.0.0"
8581cb0ef41Sopenharmony_ci  }
8591cb0ef41Sopenharmony_ci}
8601cb0ef41Sopenharmony_ci</code></pre>
8611cb0ef41Sopenharmony_ci<p>The above is a short hand notation, the full object form can be used to allow
8621cb0ef41Sopenharmony_cioverriding a package itself as well as a child of the package. This will cause
8631cb0ef41Sopenharmony_ci<code>foo</code> to always be <code>1.0.0</code> while also making <code>bar</code> at any depth beyond <code>foo</code>
8641cb0ef41Sopenharmony_cialso <code>1.0.0</code>:</p>
8651cb0ef41Sopenharmony_ci<pre><code class="language-json">{
8661cb0ef41Sopenharmony_ci  "overrides": {
8671cb0ef41Sopenharmony_ci    "foo": {
8681cb0ef41Sopenharmony_ci      ".": "1.0.0",
8691cb0ef41Sopenharmony_ci      "bar": "1.0.0"
8701cb0ef41Sopenharmony_ci    }
8711cb0ef41Sopenharmony_ci  }
8721cb0ef41Sopenharmony_ci}
8731cb0ef41Sopenharmony_ci</code></pre>
8741cb0ef41Sopenharmony_ci<p>To only override <code>foo</code> to be <code>1.0.0</code> when it's a child (or grandchild, or great
8751cb0ef41Sopenharmony_cigrandchild, etc) of the package <code>bar</code>:</p>
8761cb0ef41Sopenharmony_ci<pre><code class="language-json">{
8771cb0ef41Sopenharmony_ci  "overrides": {
8781cb0ef41Sopenharmony_ci    "bar": {
8791cb0ef41Sopenharmony_ci      "foo": "1.0.0"
8801cb0ef41Sopenharmony_ci    }
8811cb0ef41Sopenharmony_ci  }
8821cb0ef41Sopenharmony_ci}
8831cb0ef41Sopenharmony_ci</code></pre>
8841cb0ef41Sopenharmony_ci<p>Keys can be nested to any arbitrary length. To override <code>foo</code> only when it's a
8851cb0ef41Sopenharmony_cichild of <code>bar</code> and only when <code>bar</code> is a child of <code>baz</code>:</p>
8861cb0ef41Sopenharmony_ci<pre><code class="language-json">{
8871cb0ef41Sopenharmony_ci  "overrides": {
8881cb0ef41Sopenharmony_ci    "baz": {
8891cb0ef41Sopenharmony_ci      "bar": {
8901cb0ef41Sopenharmony_ci        "foo": "1.0.0"
8911cb0ef41Sopenharmony_ci      }
8921cb0ef41Sopenharmony_ci    }
8931cb0ef41Sopenharmony_ci  }
8941cb0ef41Sopenharmony_ci}
8951cb0ef41Sopenharmony_ci</code></pre>
8961cb0ef41Sopenharmony_ci<p>The key of an override can also include a version, or range of versions.
8971cb0ef41Sopenharmony_ciTo override <code>foo</code> to <code>1.0.0</code>, but only when it's a child of <code>bar@2.0.0</code>:</p>
8981cb0ef41Sopenharmony_ci<pre><code class="language-json">{
8991cb0ef41Sopenharmony_ci  "overrides": {
9001cb0ef41Sopenharmony_ci    "bar@2.0.0": {
9011cb0ef41Sopenharmony_ci      "foo": "1.0.0"
9021cb0ef41Sopenharmony_ci    }
9031cb0ef41Sopenharmony_ci  }
9041cb0ef41Sopenharmony_ci}
9051cb0ef41Sopenharmony_ci</code></pre>
9061cb0ef41Sopenharmony_ci<p>You may not set an override for a package that you directly depend on unless
9071cb0ef41Sopenharmony_ciboth the dependency and the override itself share the exact same spec. To make
9081cb0ef41Sopenharmony_cithis limitation easier to deal with, overrides may also be defined as a
9091cb0ef41Sopenharmony_cireference to a spec for a direct dependency by prefixing the name of the
9101cb0ef41Sopenharmony_cipackage you wish the version to match with a <code>$</code>.</p>
9111cb0ef41Sopenharmony_ci<pre><code class="language-json">{
9121cb0ef41Sopenharmony_ci  "dependencies": {
9131cb0ef41Sopenharmony_ci    "foo": "^1.0.0"
9141cb0ef41Sopenharmony_ci  },
9151cb0ef41Sopenharmony_ci  "overrides": {
9161cb0ef41Sopenharmony_ci    // BAD, will throw an EOVERRIDE error
9171cb0ef41Sopenharmony_ci    // "foo": "^2.0.0"
9181cb0ef41Sopenharmony_ci    // GOOD, specs match so override is allowed
9191cb0ef41Sopenharmony_ci    // "foo": "^1.0.0"
9201cb0ef41Sopenharmony_ci    // BEST, the override is defined as a reference to the dependency
9211cb0ef41Sopenharmony_ci    "foo": "$foo",
9221cb0ef41Sopenharmony_ci    // the referenced package does not need to match the overridden one
9231cb0ef41Sopenharmony_ci    "bar": "$foo"
9241cb0ef41Sopenharmony_ci  }
9251cb0ef41Sopenharmony_ci}
9261cb0ef41Sopenharmony_ci</code></pre>
9271cb0ef41Sopenharmony_ci<h3 id="engines">engines</h3>
9281cb0ef41Sopenharmony_ci<p>You can specify the version of node that your stuff works on:</p>
9291cb0ef41Sopenharmony_ci<pre><code class="language-json">{
9301cb0ef41Sopenharmony_ci  "engines": {
9311cb0ef41Sopenharmony_ci    "node": "&gt;=0.10.3 &lt;15"
9321cb0ef41Sopenharmony_ci  }
9331cb0ef41Sopenharmony_ci}
9341cb0ef41Sopenharmony_ci</code></pre>
9351cb0ef41Sopenharmony_ci<p>And, like with dependencies, if you don't specify the version (or if you
9361cb0ef41Sopenharmony_cispecify "*" as the version), then any version of node will do.</p>
9371cb0ef41Sopenharmony_ci<p>You can also use the "engines" field to specify which versions of npm are
9381cb0ef41Sopenharmony_cicapable of properly installing your program.  For example:</p>
9391cb0ef41Sopenharmony_ci<pre><code class="language-json">{
9401cb0ef41Sopenharmony_ci  "engines": {
9411cb0ef41Sopenharmony_ci    "npm": "~1.0.20"
9421cb0ef41Sopenharmony_ci  }
9431cb0ef41Sopenharmony_ci}
9441cb0ef41Sopenharmony_ci</code></pre>
9451cb0ef41Sopenharmony_ci<p>Unless the user has set the
9461cb0ef41Sopenharmony_ci<a href="../using-npm/config#engine-strict.html"><code>engine-strict</code> config</a> flag, this field is
9471cb0ef41Sopenharmony_ciadvisory only and will only produce warnings when your package is installed as a
9481cb0ef41Sopenharmony_cidependency.</p>
9491cb0ef41Sopenharmony_ci<h3 id="os">os</h3>
9501cb0ef41Sopenharmony_ci<p>You can specify which operating systems your
9511cb0ef41Sopenharmony_cimodule will run on:</p>
9521cb0ef41Sopenharmony_ci<pre><code class="language-json">{
9531cb0ef41Sopenharmony_ci  "os": [
9541cb0ef41Sopenharmony_ci    "darwin",
9551cb0ef41Sopenharmony_ci    "linux"
9561cb0ef41Sopenharmony_ci  ]
9571cb0ef41Sopenharmony_ci}
9581cb0ef41Sopenharmony_ci</code></pre>
9591cb0ef41Sopenharmony_ci<p>You can also block instead of allowing operating systems, just prepend the
9601cb0ef41Sopenharmony_ciblocked os with a '!':</p>
9611cb0ef41Sopenharmony_ci<pre><code class="language-json">{
9621cb0ef41Sopenharmony_ci  "os": [
9631cb0ef41Sopenharmony_ci    "!win32"
9641cb0ef41Sopenharmony_ci  ]
9651cb0ef41Sopenharmony_ci}
9661cb0ef41Sopenharmony_ci</code></pre>
9671cb0ef41Sopenharmony_ci<p>The host operating system is determined by <code>process.platform</code></p>
9681cb0ef41Sopenharmony_ci<p>It is allowed to both block and allow an item, although there isn't any
9691cb0ef41Sopenharmony_cigood reason to do this.</p>
9701cb0ef41Sopenharmony_ci<h3 id="cpu">cpu</h3>
9711cb0ef41Sopenharmony_ci<p>If your code only runs on certain cpu architectures,
9721cb0ef41Sopenharmony_ciyou can specify which ones.</p>
9731cb0ef41Sopenharmony_ci<pre><code class="language-json">{
9741cb0ef41Sopenharmony_ci  "cpu": [
9751cb0ef41Sopenharmony_ci    "x64",
9761cb0ef41Sopenharmony_ci    "ia32"
9771cb0ef41Sopenharmony_ci  ]
9781cb0ef41Sopenharmony_ci}
9791cb0ef41Sopenharmony_ci</code></pre>
9801cb0ef41Sopenharmony_ci<p>Like the <code>os</code> option, you can also block architectures:</p>
9811cb0ef41Sopenharmony_ci<pre><code class="language-json">{
9821cb0ef41Sopenharmony_ci  "cpu": [
9831cb0ef41Sopenharmony_ci    "!arm",
9841cb0ef41Sopenharmony_ci    "!mips"
9851cb0ef41Sopenharmony_ci  ]
9861cb0ef41Sopenharmony_ci}
9871cb0ef41Sopenharmony_ci</code></pre>
9881cb0ef41Sopenharmony_ci<p>The host architecture is determined by <code>process.arch</code></p>
9891cb0ef41Sopenharmony_ci<h3 id="private">private</h3>
9901cb0ef41Sopenharmony_ci<p>If you set <code>"private": true</code> in your package.json, then npm will refuse to
9911cb0ef41Sopenharmony_cipublish it.</p>
9921cb0ef41Sopenharmony_ci<p>This is a way to prevent accidental publication of private repositories.
9931cb0ef41Sopenharmony_ciIf you would like to ensure that a given package is only ever published to
9941cb0ef41Sopenharmony_cia specific registry (for example, an internal registry), then use the
9951cb0ef41Sopenharmony_ci<code>publishConfig</code> dictionary described below to override the <code>registry</code>
9961cb0ef41Sopenharmony_ciconfig param at publish-time.</p>
9971cb0ef41Sopenharmony_ci<h3 id="publishconfig">publishConfig</h3>
9981cb0ef41Sopenharmony_ci<p>This is a set of config values that will be used at publish-time. It's
9991cb0ef41Sopenharmony_ciespecially handy if you want to set the tag, registry or access, so that
10001cb0ef41Sopenharmony_ciyou can ensure that a given package is not tagged with "latest", published
10011cb0ef41Sopenharmony_cito the global public registry or that a scoped module is private by
10021cb0ef41Sopenharmony_cidefault.</p>
10031cb0ef41Sopenharmony_ci<p>See <a href="../using-npm/config.html"><code>config</code></a> to see the list of config options that
10041cb0ef41Sopenharmony_cican be overridden.</p>
10051cb0ef41Sopenharmony_ci<h3 id="workspaces">workspaces</h3>
10061cb0ef41Sopenharmony_ci<p>The optional <code>workspaces</code> field is an array of file patterns that describes
10071cb0ef41Sopenharmony_cilocations within the local file system that the install client should look
10081cb0ef41Sopenharmony_ciup to find each <a href="../using-npm/workspaces.html">workspace</a> that needs to be
10091cb0ef41Sopenharmony_cisymlinked to the top level <code>node_modules</code> folder.</p>
10101cb0ef41Sopenharmony_ci<p>It can describe either the direct paths of the folders to be used as
10111cb0ef41Sopenharmony_ciworkspaces or it can define globs that will resolve to these same folders.</p>
10121cb0ef41Sopenharmony_ci<p>In the following example, all folders located inside the folder
10131cb0ef41Sopenharmony_ci<code>./packages</code> will be treated as workspaces as long as they have valid
10141cb0ef41Sopenharmony_ci<code>package.json</code> files inside them:</p>
10151cb0ef41Sopenharmony_ci<pre><code class="language-json">{
10161cb0ef41Sopenharmony_ci  "name": "workspace-example",
10171cb0ef41Sopenharmony_ci  "workspaces": [
10181cb0ef41Sopenharmony_ci    "./packages/*"
10191cb0ef41Sopenharmony_ci  ]
10201cb0ef41Sopenharmony_ci}
10211cb0ef41Sopenharmony_ci</code></pre>
10221cb0ef41Sopenharmony_ci<p>See <a href="../using-npm/workspaces.html"><code>workspaces</code></a> for more examples.</p>
10231cb0ef41Sopenharmony_ci<h3 id="default-values">DEFAULT VALUES</h3>
10241cb0ef41Sopenharmony_ci<p>npm will default some values based on package contents.</p>
10251cb0ef41Sopenharmony_ci<ul>
10261cb0ef41Sopenharmony_ci<li>
10271cb0ef41Sopenharmony_ci<p><code>"scripts": {"start": "node server.js"}</code></p>
10281cb0ef41Sopenharmony_ci<p>If there is a <code>server.js</code> file in the root of your package, then npm will
10291cb0ef41Sopenharmony_cidefault the <code>start</code> command to <code>node server.js</code>.</p>
10301cb0ef41Sopenharmony_ci</li>
10311cb0ef41Sopenharmony_ci<li>
10321cb0ef41Sopenharmony_ci<p><code>"scripts":{"install": "node-gyp rebuild"}</code></p>
10331cb0ef41Sopenharmony_ci<p>If there is a <code>binding.gyp</code> file in the root of your package and you have
10341cb0ef41Sopenharmony_cinot defined an <code>install</code> or <code>preinstall</code> script, npm will default the
10351cb0ef41Sopenharmony_ci<code>install</code> command to compile using node-gyp.</p>
10361cb0ef41Sopenharmony_ci</li>
10371cb0ef41Sopenharmony_ci<li>
10381cb0ef41Sopenharmony_ci<p><code>"contributors": [...]</code></p>
10391cb0ef41Sopenharmony_ci<p>If there is an <code>AUTHORS</code> file in the root of your package, npm will treat
10401cb0ef41Sopenharmony_cieach line as a <code>Name &lt;email&gt; (url)</code> format, where email and url are
10411cb0ef41Sopenharmony_cioptional.  Lines which start with a <code>#</code> or are blank, will be ignored.</p>
10421cb0ef41Sopenharmony_ci</li>
10431cb0ef41Sopenharmony_ci</ul>
10441cb0ef41Sopenharmony_ci<h3 id="see-also">SEE ALSO</h3>
10451cb0ef41Sopenharmony_ci<ul>
10461cb0ef41Sopenharmony_ci<li><a href="https://github.com/npm/node-semver#versions">semver</a></li>
10471cb0ef41Sopenharmony_ci<li><a href="../using-npm/workspaces.html">workspaces</a></li>
10481cb0ef41Sopenharmony_ci<li><a href="../commands/npm-init.html">npm init</a></li>
10491cb0ef41Sopenharmony_ci<li><a href="../commands/npm-version.html">npm version</a></li>
10501cb0ef41Sopenharmony_ci<li><a href="../commands/npm-config.html">npm config</a></li>
10511cb0ef41Sopenharmony_ci<li><a href="../commands/npm-help.html">npm help</a></li>
10521cb0ef41Sopenharmony_ci<li><a href="../commands/npm-install.html">npm install</a></li>
10531cb0ef41Sopenharmony_ci<li><a href="../commands/npm-publish.html">npm publish</a></li>
10541cb0ef41Sopenharmony_ci<li><a href="../commands/npm-uninstall.html">npm uninstall</a></li>
10551cb0ef41Sopenharmony_ci</ul></div>
10561cb0ef41Sopenharmony_ci
10571cb0ef41Sopenharmony_ci<footer id="edit">
10581cb0ef41Sopenharmony_ci<a href="https://github.com/npm/cli/edit/latest/docs/content/configuring-npm/package-json.md">
10591cb0ef41Sopenharmony_ci<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
10601cb0ef41Sopenharmony_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>
10611cb0ef41Sopenharmony_ci</svg>
10621cb0ef41Sopenharmony_ciEdit this page on GitHub
10631cb0ef41Sopenharmony_ci</a>
10641cb0ef41Sopenharmony_ci</footer>
10651cb0ef41Sopenharmony_ci</section>
10661cb0ef41Sopenharmony_ci
10671cb0ef41Sopenharmony_ci
10681cb0ef41Sopenharmony_ci
10691cb0ef41Sopenharmony_ci</body></html>