11cb0ef41Sopenharmony_ci<!DOCTYPE html><html><head>
21cb0ef41Sopenharmony_ci<meta charset="utf-8">
31cb0ef41Sopenharmony_ci<title>npm-init</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-init">npm-init</h1>
1401cb0ef41Sopenharmony_ci<span class="description">Create a package.json file</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><ul><li><a href="#forwarding-additional-options">Forwarding additional options</a></li></ul><li><a href="#examples">Examples</a></li><li><a href="#workspaces-support">Workspaces support</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#init-author-name"><code>init-author-name</code></a></li><li><a href="#init-author-url"><code>init-author-url</code></a></li><li><a href="#init-license"><code>init-license</code></a></li><li><a href="#init-module"><code>init-module</code></a></li><li><a href="#init-version"><code>init-version</code></a></li><li><a href="#yes"><code>yes</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#scope"><code>scope</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#workspaces-update"><code>workspaces-update</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><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 init &lt;package-spec&gt; (same as `npx &lt;package-spec&gt;`)
1501cb0ef41Sopenharmony_cinpm init &lt;@scope&gt; (same as `npx &lt;@scope&gt;/create`)
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_cialiases: create, innit
1531cb0ef41Sopenharmony_ci</code></pre>
1541cb0ef41Sopenharmony_ci<h3 id="description">Description</h3>
1551cb0ef41Sopenharmony_ci<p><code>npm init &lt;initializer&gt;</code> can be used to set up a new or existing npm
1561cb0ef41Sopenharmony_cipackage.</p>
1571cb0ef41Sopenharmony_ci<p><code>initializer</code> in this case is an npm package named <code>create-&lt;initializer&gt;</code>,
1581cb0ef41Sopenharmony_ciwhich will be installed by <a href="../commands/npm-exec.html"><code>npm-exec</code></a>, and then have its
1591cb0ef41Sopenharmony_cimain bin executed -- presumably creating or updating <code>package.json</code> and
1601cb0ef41Sopenharmony_cirunning any other initialization-related operations.</p>
1611cb0ef41Sopenharmony_ci<p>The init command is transformed to a corresponding <code>npm exec</code> operation as
1621cb0ef41Sopenharmony_cifollows:</p>
1631cb0ef41Sopenharmony_ci<ul>
1641cb0ef41Sopenharmony_ci<li><code>npm init foo</code> -&gt; <code>npm exec create-foo</code></li>
1651cb0ef41Sopenharmony_ci<li><code>npm init @usr/foo</code> -&gt; <code>npm exec @usr/create-foo</code></li>
1661cb0ef41Sopenharmony_ci<li><code>npm init @usr</code> -&gt; <code>npm exec @usr/create</code></li>
1671cb0ef41Sopenharmony_ci<li><code>npm init @usr@2.0.0</code> -&gt; <code>npm exec @usr/create@2.0.0</code></li>
1681cb0ef41Sopenharmony_ci<li><code>npm init @usr/foo@2.0.0</code> -&gt; <code>npm exec @usr/create-foo@2.0.0</code></li>
1691cb0ef41Sopenharmony_ci</ul>
1701cb0ef41Sopenharmony_ci<p>If the initializer is omitted (by just calling <code>npm init</code>), init will fall
1711cb0ef41Sopenharmony_ciback to legacy init behavior. It will ask you a bunch of questions, and
1721cb0ef41Sopenharmony_cithen write a package.json for you. It will attempt to make reasonable
1731cb0ef41Sopenharmony_ciguesses based on existing fields, dependencies, and options selected. It is
1741cb0ef41Sopenharmony_cistrictly additive, so it will keep any fields and values that were already
1751cb0ef41Sopenharmony_ciset. You can also use <code>-y</code>/<code>--yes</code> to skip the questionnaire altogether. If
1761cb0ef41Sopenharmony_ciyou pass <code>--scope</code>, it will create a scoped package.</p>
1771cb0ef41Sopenharmony_ci<p><em>Note:</em> if a user already has the <code>create-&lt;initializer&gt;</code> package
1781cb0ef41Sopenharmony_ciglobally installed, that will be what <code>npm init</code> uses.  If you want npm
1791cb0ef41Sopenharmony_cito use the latest version, or another specific version you must specify
1801cb0ef41Sopenharmony_ciit:</p>
1811cb0ef41Sopenharmony_ci<ul>
1821cb0ef41Sopenharmony_ci<li><code>npm init foo@latest</code> # fetches and runs the latest <code>create-foo</code> from
1831cb0ef41Sopenharmony_cithe registry</li>
1841cb0ef41Sopenharmony_ci<li><code>npm init foo@1.2.3</code> #  runs <code>create-foo@1.2.3</code> specifically</li>
1851cb0ef41Sopenharmony_ci</ul>
1861cb0ef41Sopenharmony_ci<h4 id="forwarding-additional-options">Forwarding additional options</h4>
1871cb0ef41Sopenharmony_ci<p>Any additional options will be passed directly to the command, so <code>npm init foo -- --hello</code> will map to <code>npm exec -- create-foo --hello</code>.</p>
1881cb0ef41Sopenharmony_ci<p>To better illustrate how options are forwarded, here's a more evolved
1891cb0ef41Sopenharmony_ciexample showing options passed to both the <strong>npm cli</strong> and a create package,
1901cb0ef41Sopenharmony_ciboth following commands are equivalent:</p>
1911cb0ef41Sopenharmony_ci<ul>
1921cb0ef41Sopenharmony_ci<li><code>npm init foo -y --registry=&lt;url&gt; -- --hello -a</code></li>
1931cb0ef41Sopenharmony_ci<li><code>npm exec -y --registry=&lt;url&gt; -- create-foo --hello -a</code></li>
1941cb0ef41Sopenharmony_ci</ul>
1951cb0ef41Sopenharmony_ci<h3 id="examples">Examples</h3>
1961cb0ef41Sopenharmony_ci<p>Create a new React-based project using
1971cb0ef41Sopenharmony_ci<a href="https://npm.im/create-react-app"><code>create-react-app</code></a>:</p>
1981cb0ef41Sopenharmony_ci<pre><code class="language-bash">$ npm init react-app ./my-react-app
1991cb0ef41Sopenharmony_ci</code></pre>
2001cb0ef41Sopenharmony_ci<p>Create a new <code>esm</code>-compatible package using
2011cb0ef41Sopenharmony_ci<a href="https://npm.im/create-esm"><code>create-esm</code></a>:</p>
2021cb0ef41Sopenharmony_ci<pre><code class="language-bash">$ mkdir my-esm-lib &amp;&amp; cd my-esm-lib
2031cb0ef41Sopenharmony_ci$ npm init esm --yes
2041cb0ef41Sopenharmony_ci</code></pre>
2051cb0ef41Sopenharmony_ci<p>Generate a plain old package.json using legacy init:</p>
2061cb0ef41Sopenharmony_ci<pre><code class="language-bash">$ mkdir my-npm-pkg &amp;&amp; cd my-npm-pkg
2071cb0ef41Sopenharmony_ci$ git init
2081cb0ef41Sopenharmony_ci$ npm init
2091cb0ef41Sopenharmony_ci</code></pre>
2101cb0ef41Sopenharmony_ci<p>Generate it without having it ask any questions:</p>
2111cb0ef41Sopenharmony_ci<pre><code class="language-bash">$ npm init -y
2121cb0ef41Sopenharmony_ci</code></pre>
2131cb0ef41Sopenharmony_ci<h3 id="workspaces-support">Workspaces support</h3>
2141cb0ef41Sopenharmony_ci<p>It's possible to create a new workspace within your project by using the
2151cb0ef41Sopenharmony_ci<code>workspace</code> config option. When using <code>npm init -w &lt;dir&gt;</code> the cli will
2161cb0ef41Sopenharmony_cicreate the folders and boilerplate expected while also adding a reference
2171cb0ef41Sopenharmony_cito your project <code>package.json</code> <code>"workspaces": []</code> property in order to make
2181cb0ef41Sopenharmony_cisure that new generated <strong>workspace</strong> is properly set up as such.</p>
2191cb0ef41Sopenharmony_ci<p>Given a project with no workspaces, e.g:</p>
2201cb0ef41Sopenharmony_ci<pre><code>.
2211cb0ef41Sopenharmony_ci+-- package.json
2221cb0ef41Sopenharmony_ci</code></pre>
2231cb0ef41Sopenharmony_ci<p>You may generate a new workspace using the legacy init:</p>
2241cb0ef41Sopenharmony_ci<pre><code class="language-bash">$ npm init -w packages/a
2251cb0ef41Sopenharmony_ci</code></pre>
2261cb0ef41Sopenharmony_ci<p>That will generate a new folder and <code>package.json</code> file, while also updating
2271cb0ef41Sopenharmony_ciyour top-level <code>package.json</code> to add the reference to this new workspace:</p>
2281cb0ef41Sopenharmony_ci<pre><code>.
2291cb0ef41Sopenharmony_ci+-- package.json
2301cb0ef41Sopenharmony_ci`-- packages
2311cb0ef41Sopenharmony_ci   `-- a
2321cb0ef41Sopenharmony_ci       `-- package.json
2331cb0ef41Sopenharmony_ci</code></pre>
2341cb0ef41Sopenharmony_ci<p>The workspaces init also supports the <code>npm init &lt;initializer&gt; -w &lt;dir&gt;</code>
2351cb0ef41Sopenharmony_cisyntax, following the same set of rules explained earlier in the initial
2361cb0ef41Sopenharmony_ci<strong>Description</strong> section of this page. Similar to the previous example of
2371cb0ef41Sopenharmony_cicreating a new React-based project using
2381cb0ef41Sopenharmony_ci<a href="https://npm.im/create-react-app"><code>create-react-app</code></a>, the following syntax
2391cb0ef41Sopenharmony_ciwill make sure to create the new react app as a nested <strong>workspace</strong> within your
2401cb0ef41Sopenharmony_ciproject and configure your <code>package.json</code> to recognize it as such:</p>
2411cb0ef41Sopenharmony_ci<pre><code class="language-bash">npm init -w packages/my-react-app react-app .
2421cb0ef41Sopenharmony_ci</code></pre>
2431cb0ef41Sopenharmony_ci<p>This will make sure to generate your react app as expected, one important
2441cb0ef41Sopenharmony_ciconsideration to have in mind is that <code>npm exec</code> is going to be run in the
2451cb0ef41Sopenharmony_cicontext of the newly created folder for that workspace, and that's the reason
2461cb0ef41Sopenharmony_ciwhy in this example the initializer uses the initializer name followed with a
2471cb0ef41Sopenharmony_cidot to represent the current directory in that context, e.g: <code>react-app .</code>:</p>
2481cb0ef41Sopenharmony_ci<pre><code>.
2491cb0ef41Sopenharmony_ci+-- package.json
2501cb0ef41Sopenharmony_ci`-- packages
2511cb0ef41Sopenharmony_ci   +-- a
2521cb0ef41Sopenharmony_ci   |   `-- package.json
2531cb0ef41Sopenharmony_ci   `-- my-react-app
2541cb0ef41Sopenharmony_ci       +-- README
2551cb0ef41Sopenharmony_ci       +-- package.json
2561cb0ef41Sopenharmony_ci       `-- ...
2571cb0ef41Sopenharmony_ci</code></pre>
2581cb0ef41Sopenharmony_ci<h3 id="configuration">Configuration</h3>
2591cb0ef41Sopenharmony_ci<h4 id="init-author-name"><code>init-author-name</code></h4>
2601cb0ef41Sopenharmony_ci<ul>
2611cb0ef41Sopenharmony_ci<li>Default: ""</li>
2621cb0ef41Sopenharmony_ci<li>Type: String</li>
2631cb0ef41Sopenharmony_ci</ul>
2641cb0ef41Sopenharmony_ci<p>The value <code>npm init</code> should use by default for the package author's name.</p>
2651cb0ef41Sopenharmony_ci<h4 id="init-author-url"><code>init-author-url</code></h4>
2661cb0ef41Sopenharmony_ci<ul>
2671cb0ef41Sopenharmony_ci<li>Default: ""</li>
2681cb0ef41Sopenharmony_ci<li>Type: "" or URL</li>
2691cb0ef41Sopenharmony_ci</ul>
2701cb0ef41Sopenharmony_ci<p>The value <code>npm init</code> should use by default for the package author's
2711cb0ef41Sopenharmony_cihomepage.</p>
2721cb0ef41Sopenharmony_ci<h4 id="init-license"><code>init-license</code></h4>
2731cb0ef41Sopenharmony_ci<ul>
2741cb0ef41Sopenharmony_ci<li>Default: "ISC"</li>
2751cb0ef41Sopenharmony_ci<li>Type: String</li>
2761cb0ef41Sopenharmony_ci</ul>
2771cb0ef41Sopenharmony_ci<p>The value <code>npm init</code> should use by default for the package license.</p>
2781cb0ef41Sopenharmony_ci<h4 id="init-module"><code>init-module</code></h4>
2791cb0ef41Sopenharmony_ci<ul>
2801cb0ef41Sopenharmony_ci<li>Default: "~/.npm-init.js"</li>
2811cb0ef41Sopenharmony_ci<li>Type: Path</li>
2821cb0ef41Sopenharmony_ci</ul>
2831cb0ef41Sopenharmony_ci<p>A module that will be loaded by the <code>npm init</code> command. See the
2841cb0ef41Sopenharmony_cidocumentation for the
2851cb0ef41Sopenharmony_ci<a href="https://github.com/npm/init-package-json">init-package-json</a> module for
2861cb0ef41Sopenharmony_cimore information, or <a href="../commands/npm-init.html">npm init</a>.</p>
2871cb0ef41Sopenharmony_ci<h4 id="init-version"><code>init-version</code></h4>
2881cb0ef41Sopenharmony_ci<ul>
2891cb0ef41Sopenharmony_ci<li>Default: "1.0.0"</li>
2901cb0ef41Sopenharmony_ci<li>Type: SemVer string</li>
2911cb0ef41Sopenharmony_ci</ul>
2921cb0ef41Sopenharmony_ci<p>The value that <code>npm init</code> should use by default for the package version
2931cb0ef41Sopenharmony_cinumber, if not already set in package.json.</p>
2941cb0ef41Sopenharmony_ci<h4 id="yes"><code>yes</code></h4>
2951cb0ef41Sopenharmony_ci<ul>
2961cb0ef41Sopenharmony_ci<li>Default: null</li>
2971cb0ef41Sopenharmony_ci<li>Type: null or Boolean</li>
2981cb0ef41Sopenharmony_ci</ul>
2991cb0ef41Sopenharmony_ci<p>Automatically answer "yes" to any prompts that npm might print on the
3001cb0ef41Sopenharmony_cicommand line.</p>
3011cb0ef41Sopenharmony_ci<h4 id="force"><code>force</code></h4>
3021cb0ef41Sopenharmony_ci<ul>
3031cb0ef41Sopenharmony_ci<li>Default: false</li>
3041cb0ef41Sopenharmony_ci<li>Type: Boolean</li>
3051cb0ef41Sopenharmony_ci</ul>
3061cb0ef41Sopenharmony_ci<p>Removes various protections against unfortunate side effects, common
3071cb0ef41Sopenharmony_cimistakes, unnecessary performance degradation, and malicious input.</p>
3081cb0ef41Sopenharmony_ci<ul>
3091cb0ef41Sopenharmony_ci<li>Allow clobbering non-npm files in global installs.</li>
3101cb0ef41Sopenharmony_ci<li>Allow the <code>npm version</code> command to work on an unclean git repository.</li>
3111cb0ef41Sopenharmony_ci<li>Allow deleting the cache folder with <code>npm cache clean</code>.</li>
3121cb0ef41Sopenharmony_ci<li>Allow installing packages that have an <code>engines</code> declaration requiring a
3131cb0ef41Sopenharmony_cidifferent version of npm.</li>
3141cb0ef41Sopenharmony_ci<li>Allow installing packages that have an <code>engines</code> declaration requiring a
3151cb0ef41Sopenharmony_cidifferent version of <code>node</code>, even if <code>--engine-strict</code> is enabled.</li>
3161cb0ef41Sopenharmony_ci<li>Allow <code>npm audit fix</code> to install modules outside your stated dependency
3171cb0ef41Sopenharmony_cirange (including SemVer-major changes).</li>
3181cb0ef41Sopenharmony_ci<li>Allow unpublishing all versions of a published package.</li>
3191cb0ef41Sopenharmony_ci<li>Allow conflicting peerDependencies to be installed in the root project.</li>
3201cb0ef41Sopenharmony_ci<li>Implicitly set <code>--yes</code> during <code>npm init</code>.</li>
3211cb0ef41Sopenharmony_ci<li>Allow clobbering existing values in <code>npm pkg</code></li>
3221cb0ef41Sopenharmony_ci<li>Allow unpublishing of entire packages (not just a single version).</li>
3231cb0ef41Sopenharmony_ci</ul>
3241cb0ef41Sopenharmony_ci<p>If you don't have a clear idea of what you want to do, it is strongly
3251cb0ef41Sopenharmony_cirecommended that you do not use this option!</p>
3261cb0ef41Sopenharmony_ci<h4 id="scope"><code>scope</code></h4>
3271cb0ef41Sopenharmony_ci<ul>
3281cb0ef41Sopenharmony_ci<li>Default: the scope of the current project, if any, or ""</li>
3291cb0ef41Sopenharmony_ci<li>Type: String</li>
3301cb0ef41Sopenharmony_ci</ul>
3311cb0ef41Sopenharmony_ci<p>Associate an operation with a scope for a scoped registry.</p>
3321cb0ef41Sopenharmony_ci<p>Useful when logging in to or out of a private registry:</p>
3331cb0ef41Sopenharmony_ci<pre><code># log in, linking the scope to the custom registry
3341cb0ef41Sopenharmony_cinpm login --scope=@mycorp --registry=https://registry.mycorp.com
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci# log out, removing the link and the auth token
3371cb0ef41Sopenharmony_cinpm logout --scope=@mycorp
3381cb0ef41Sopenharmony_ci</code></pre>
3391cb0ef41Sopenharmony_ci<p>This will cause <code>@mycorp</code> to be mapped to the registry for future
3401cb0ef41Sopenharmony_ciinstallation of packages specified according to the pattern
3411cb0ef41Sopenharmony_ci<code>@mycorp/package</code>.</p>
3421cb0ef41Sopenharmony_ci<p>This will also cause <code>npm init</code> to create a scoped package.</p>
3431cb0ef41Sopenharmony_ci<pre><code># accept all defaults, and create a package named "@foo/whatever",
3441cb0ef41Sopenharmony_ci# instead of just named "whatever"
3451cb0ef41Sopenharmony_cinpm init --scope=@foo --yes
3461cb0ef41Sopenharmony_ci</code></pre>
3471cb0ef41Sopenharmony_ci<h4 id="workspace"><code>workspace</code></h4>
3481cb0ef41Sopenharmony_ci<ul>
3491cb0ef41Sopenharmony_ci<li>Default:</li>
3501cb0ef41Sopenharmony_ci<li>Type: String (can be set multiple times)</li>
3511cb0ef41Sopenharmony_ci</ul>
3521cb0ef41Sopenharmony_ci<p>Enable running a command in the context of the configured workspaces of the
3531cb0ef41Sopenharmony_cicurrent project while filtering by running only the workspaces defined by
3541cb0ef41Sopenharmony_cithis configuration option.</p>
3551cb0ef41Sopenharmony_ci<p>Valid values for the <code>workspace</code> config are either:</p>
3561cb0ef41Sopenharmony_ci<ul>
3571cb0ef41Sopenharmony_ci<li>Workspace names</li>
3581cb0ef41Sopenharmony_ci<li>Path to a workspace directory</li>
3591cb0ef41Sopenharmony_ci<li>Path to a parent workspace directory (will result in selecting all
3601cb0ef41Sopenharmony_ciworkspaces within that folder)</li>
3611cb0ef41Sopenharmony_ci</ul>
3621cb0ef41Sopenharmony_ci<p>When set for the <code>npm init</code> command, this may be set to the folder of a
3631cb0ef41Sopenharmony_ciworkspace which does not yet exist, to create the folder and set it up as a
3641cb0ef41Sopenharmony_cibrand new workspace within the project.</p>
3651cb0ef41Sopenharmony_ci<p>This value is not exported to the environment for child processes.</p>
3661cb0ef41Sopenharmony_ci<h4 id="workspaces"><code>workspaces</code></h4>
3671cb0ef41Sopenharmony_ci<ul>
3681cb0ef41Sopenharmony_ci<li>Default: null</li>
3691cb0ef41Sopenharmony_ci<li>Type: null or Boolean</li>
3701cb0ef41Sopenharmony_ci</ul>
3711cb0ef41Sopenharmony_ci<p>Set to true to run the command in the context of <strong>all</strong> configured
3721cb0ef41Sopenharmony_ciworkspaces.</p>
3731cb0ef41Sopenharmony_ci<p>Explicitly setting this to false will cause commands like <code>install</code> to
3741cb0ef41Sopenharmony_ciignore workspaces altogether. When not set explicitly:</p>
3751cb0ef41Sopenharmony_ci<ul>
3761cb0ef41Sopenharmony_ci<li>Commands that operate on the <code>node_modules</code> tree (install, update, etc.)
3771cb0ef41Sopenharmony_ciwill link workspaces into the <code>node_modules</code> folder. - Commands that do
3781cb0ef41Sopenharmony_ciother things (test, exec, publish, etc.) will operate on the root project,
3791cb0ef41Sopenharmony_ci<em>unless</em> one or more workspaces are specified in the <code>workspace</code> config.</li>
3801cb0ef41Sopenharmony_ci</ul>
3811cb0ef41Sopenharmony_ci<p>This value is not exported to the environment for child processes.</p>
3821cb0ef41Sopenharmony_ci<h4 id="workspaces-update"><code>workspaces-update</code></h4>
3831cb0ef41Sopenharmony_ci<ul>
3841cb0ef41Sopenharmony_ci<li>Default: true</li>
3851cb0ef41Sopenharmony_ci<li>Type: Boolean</li>
3861cb0ef41Sopenharmony_ci</ul>
3871cb0ef41Sopenharmony_ci<p>If set to true, the npm cli will run an update after operations that may
3881cb0ef41Sopenharmony_cipossibly change the workspaces installed to the <code>node_modules</code> folder.</p>
3891cb0ef41Sopenharmony_ci<h4 id="include-workspace-root"><code>include-workspace-root</code></h4>
3901cb0ef41Sopenharmony_ci<ul>
3911cb0ef41Sopenharmony_ci<li>Default: false</li>
3921cb0ef41Sopenharmony_ci<li>Type: Boolean</li>
3931cb0ef41Sopenharmony_ci</ul>
3941cb0ef41Sopenharmony_ci<p>Include the workspace root when workspaces are enabled for a command.</p>
3951cb0ef41Sopenharmony_ci<p>When false, specifying individual workspaces via the <code>workspace</code> config, or
3961cb0ef41Sopenharmony_ciall workspaces via the <code>workspaces</code> flag, will cause npm to operate only on
3971cb0ef41Sopenharmony_cithe specified workspaces, and not on the root project.</p>
3981cb0ef41Sopenharmony_ci<p>This value is not exported to the environment for child processes.</p>
3991cb0ef41Sopenharmony_ci<h3 id="see-also">See Also</h3>
4001cb0ef41Sopenharmony_ci<ul>
4011cb0ef41Sopenharmony_ci<li><a href="../using-npm/package-spec.html">package spec</a></li>
4021cb0ef41Sopenharmony_ci<li><a href="http://npm.im/init-package-json">init-package-json module</a></li>
4031cb0ef41Sopenharmony_ci<li><a href="../configuring-npm/package-json.html">package.json</a></li>
4041cb0ef41Sopenharmony_ci<li><a href="../commands/npm-version.html">npm version</a></li>
4051cb0ef41Sopenharmony_ci<li><a href="../using-npm/scope.html">npm scope</a></li>
4061cb0ef41Sopenharmony_ci<li><a href="../commands/npm-exec.html">npm exec</a></li>
4071cb0ef41Sopenharmony_ci<li><a href="../using-npm/workspaces.html">npm workspaces</a></li>
4081cb0ef41Sopenharmony_ci</ul></div>
4091cb0ef41Sopenharmony_ci
4101cb0ef41Sopenharmony_ci<footer id="edit">
4111cb0ef41Sopenharmony_ci<a href="https://github.com/npm/cli/edit/latest/docs/content/commands/npm-init.md">
4121cb0ef41Sopenharmony_ci<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
4131cb0ef41Sopenharmony_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>
4141cb0ef41Sopenharmony_ci</svg>
4151cb0ef41Sopenharmony_ciEdit this page on GitHub
4161cb0ef41Sopenharmony_ci</a>
4171cb0ef41Sopenharmony_ci</footer>
4181cb0ef41Sopenharmony_ci</section>
4191cb0ef41Sopenharmony_ci
4201cb0ef41Sopenharmony_ci
4211cb0ef41Sopenharmony_ci
4221cb0ef41Sopenharmony_ci</body></html>