Lines Matching full:code
42 code {
49 pre > code {
145 …code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#g…
149 <pre><code class="language-bash">npm install [<package-spec> ...]
152 </code></pre>
159 <li><code>npm-shrinkwrap.json</code></li>
160 <li><code>package-lock.json</code></li>
161 <li><code>yarn.lock</code></li>
164 <a href="../commands/npm-shrinkwrap.html"><code>npm shrinkwrap</code></a>.</p>
165 <p>A <code>package</code> is:</p>
168 <a href="../configuring-npm/package-json.html"><code>package.json</code></a> file</li>
171 <li>d) a <code><name>@<version></code> that is published on the registry (see
172 <a href="../using-npm/registry.html"><code>registry</code></a>) with (c)</li>
173 <li>e) a <code><name>@<tag></code> (see <a href="../commands/npm-dist-tag.html"><code>n…
175 <li>f) a <code><name></code> that has a "latest" tag satisfying (e)</li>
176 <li>g) a <code><git remote url></code> that resolves to (a)</li>
184 <p><code>npm install</code> (in a package directory, no arguments):</p>
185 <p>Install the dependencies to the local <code>node_modules</code> folder.</p>
186 <p>In global mode (ie, with <code>-g</code> or <code>--global</code> appended to the command),
189 <p>By default, <code>npm install</code> will install all modules listed as
190 dependencies in <a href="../configuring-npm/package-json.html"><code>package.json</code></a>.</p>
191 <p>With the <code>--production</code> flag (or when the <code>NODE_ENV</code> environment
192 variable is set to <code>production</code>), npm will not install modules listed
193 in <code>devDependencies</code>. To install all modules listed in both
194 <code>dependencies</code> and <code>devDependencies</code> when <code>NODE_ENV</code> environment
195 variable is set to <code>production</code>, you can use <code>--production=false</code>.</p>
197 <p>NOTE: The <code>--production</code> flag has no particular meaning when adding a
202 <p><code>npm install <folder></code>:</p>
203 <p>If <code><folder></code> sits inside the root of your project, its dependencies will be in…
204 be hoisted to the top-level <code>node_modules</code> as they would for other
205 types of dependencies. If <code><folder></code> sits outside the root of your project,
206 <em>npm will not install the package dependencies</em> in the directory <code><folder></code>,
207 but it will create a symlink to <code><folder></code>.</p>
209 …egistry instead of creating a link, you would need to use the <code>--install-links</code> option.…
212 <pre><code class="language-bash">npm install ../../other-package --install-links
214 </code></pre>
217 <p><code>npm install <tarball file></code>:</p>
220 easily by using <a href="../commands/npm-link.html"><code>npm link</code></a>.</p>
223 <li>The filename <em>must</em> use <code>.tar</code>, <code>.tar.gz</code>, or <code>.tgz</code> as…
226 (usually it is called <code>package/</code>). npm strips one directory layer
227 when installing the package (an equivalent of <code>tar x --strip-components=1</code> is run).</li>
228 <li>The package must contain a <code>package.json</code> file with <code>name</code> and
229 <code>version</code> properties.</li>
232 <pre><code class="language-bash">npm install ./package.tgz
233 </code></pre>
236 <p><code>npm install <tarball url></code>:</p>
240 <pre><code class="language-bash">npm install https://github.com/indexzero/forever/tarball/v0.5.6
241 </code></pre>
244 <p><code>npm install [<@scope>/]<name></code>:</p>
245 <p>Do a <code><name>@<tag></code> install, where <code><tag></code> is the "tag" …
246 <a href="../using-npm/config#tag.html"><code>config</code></a>. The config's default value is <code…
248 <code>latest</code> on the npm registry.</p>
250 <pre><code class="language-bash">npm install sax
251 </code></pre>
252 <p><code>npm install</code> saves any specified packages into <code>dependencies</code> by default.
257 <p><code>-P, --save-prod</code>: Package will appear in your <code>dependencies</code>. This
258 is the default unless <code>-D</code> or <code>-O</code> are present.</p>
261 <p><code>-D, --save-dev</code>: Package will appear in your <code>devDependencies</code>.</p>
264 <p><code>-O, --save-optional</code>: Package will appear in your
265 <code>optionalDependencies</code>.</p>
268 <p><code>--no-save</code>: Prevents saving to <code>dependencies</code>.</p>
275 <p><code>-E, --save-exact</code>: Saved dependencies will be configured with an
279 <p><code>-B, --save-bundle</code>: Saved dependencies will also be added to your
280 <code>bundleDependencies</code> list.</p>
283 <p>Further, if you have an <code>npm-shrinkwrap.json</code> or <code>package-lock.json</code>
285 <p><code><scope></code> is optional. The package will be downloaded from the registry
288 <a href="../using-npm/scope.html"><code>scope</code></a>.</p>
293 <pre><code class="language-bash">npm install sax
300 </code></pre>
301 <p><strong>Note</strong>: If there is a file or folder named <code><name></code> in the curre…
306 <p><code>npm install <alias>@npm:<name></code>:</p>
313 …pmjs.com/package/validate-npm-package-name#naming-rules"><code>validate-npm-package-name</code></a…
315 <pre><code class="language-bash">npm install my-react@npm:react
319 </code></pre>
322 <p><code>npm install [<@scope>/]<name>@<tag></code>:</p>
327 <pre><code class="language-bash">npm install sax@latest
329 </code></pre>
332 <p><code>npm install [<@scope>/]<name>@<version></code>:</p>
336 <pre><code class="language-bash">npm install sax@0.1.1
338 </code></pre>
341 <p><code>npm install [<@scope>/]<name>@<version range></code>:</p>
344 <a href="../configuring-npm/package-json.html"><code>package.json</code></a>.</p>
348 <pre><code class="language-bash">npm install sax@">=0.1.0 <0.2.0"
350 </code></pre>
353 <p><code>npm install <git remote url></code>:</p>
355 <code>git</code>. For a full git remote url, only that URL will be attempted.</p>
356 <pre><code class="language-bash"><protocol>://[<user>[:<password>]@]<hostname&…
357 </code></pre>
358 <p><code><protocol></code> is one of <code>git</code>, <code>git+ssh</code>, <code>git+http</…
359 <code>git+file</code>.</p>
360 <p>If <code>#<commit-ish></code> is provided, it will be used to clone exactly that
361 commit. If the commit-ish has the format <code>#semver:<semver></code>, <code><semver><…
364 it would for a registry dependency. If neither <code>#<commit-ish></code> or
365 <code>#semver:<semver></code> is specified, then the default branch of the
369 <p>If the package being installed contains a <code>prepare</code> script, its
370 <code>dependencies</code> and <code>devDependencies</code> will be installed, and the prepare
375 <li><code>GIT_ASKPASS</code></li>
376 <li><code>GIT_EXEC_PATH</code></li>
377 <li><code>GIT_PROXY_COMMAND</code></li>
378 <li><code>GIT_SSH</code></li>
379 <li><code>GIT_SSH_COMMAND</code></li>
380 <li><code>GIT_SSL_CAINFO</code></li>
381 <li><code>GIT_SSL_NO_VERIFY</code></li>
385 <pre><code class="language-bash">npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
391 </code></pre>
394 <p><code>npm install <githubname>/<githubrepo>[#<commit-ish>]</code>:</p>
397 <p><code>npm install github:<githubname>/<githubrepo>[#<commit-ish>]</code>:</p>
398 <p>Install the package at <code>https://github.com/githubname/githubrepo</code> by
399 attempting to clone it using <code>git</code>.</p>
400 <p>If <code>#<commit-ish></code> is provided, it will be used to clone exactly that
401 commit. If the commit-ish has the format <code>#semver:<semver></code>, <code><semver><…
404 it would for a registry dependency. If neither <code>#<commit-ish></code> or
405 <code>#semver:<semver></code> is specified, then the default branch is used.</p>
406 <p>As with regular git dependencies, <code>dependencies</code> and <code>devDependencies</code>
407 will be installed if the package has a <code>prepare</code> script before the
410 <pre><code class="language-bash">npm install mygithubuser/myproject
412 </code></pre>
415 <p><code>npm install gist:[<githubname>/]<gistID>[#<commit-ish>|#semver:<semve…
416 <p>Install the package at <code>https://gist.github.com/gistID</code> by attempting to
417 clone it using <code>git</code>. The GitHub username associated with the gist is
418 optional and will not be saved in <code>package.json</code>.</p>
419 <p>As with regular git dependencies, <code>dependencies</code> and <code>devDependencies</code> will
420 be installed if the package has a <code>prepare</code> script before the package is
423 <pre><code class="language-bash">npm install gist:101a11beef
424 </code></pre>
427 <p><code>npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]</co…
428 <p>Install the package at <code>https://bitbucket.org/bitbucketname/bitbucketrepo</code>
429 by attempting to clone it using <code>git</code>.</p>
430 <p>If <code>#<commit-ish></code> is provided, it will be used to clone exactly that
431 commit. If the commit-ish has the format <code>#semver:<semver></code>, <code><semver><…
434 registry dependency. If neither <code>#<commit-ish></code> or <code>#semver:<semver></c…
435 specified, then <code>master</code> is used.</p>
436 <p>As with regular git dependencies, <code>dependencies</code> and <code>devDependencies</code> will
437 be installed if the package has a <code>prepare</code> script before the package is
440 <pre><code class="language-bash">npm install bitbucket:mybitbucketuser/myproject
441 </code></pre>
444 <p><code>npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]</code>:</p>
445 <p>Install the package at <code>https://gitlab.com/gitlabname/gitlabrepo</code>
446 by attempting to clone it using <code>git</code>.</p>
447 <p>If <code>#<commit-ish></code> is provided, it will be used to clone exactly that
448 commit. If the commit-ish has the format <code>#semver:<semver></code>, <code><semver><…
451 registry dependency. If neither <code>#<commit-ish></code> or <code>#semver:<semver></c…
452 specified, then <code>master</code> is used.</p>
453 <p>As with regular git dependencies, <code>dependencies</code> and <code>devDependencies</code> will
454 be installed if the package has a <code>prepare</code> script before the package is
457 <pre><code class="language-bash">npm install gitlab:mygitlabuser/myproject
459 </code></pre>
464 <pre><code class="language-bash">npm install sax@">=0.1.0 <0.2.0" bench supervisor
465 </code></pre>
466 <p>The <code>--tag</code> argument will apply to all of the specified install targets. If
469 <p>The <code>--dry-run</code> argument will report in the usual way what the install
471 <p>The <code>--package-lock-only</code> argument will only update the
472 <code>package-lock.json</code>, instead of checking <code>node_modules</code> and downloading
474 <p>The <code>-f</code> or <code>--force</code> argument will force npm to fetch remote resources
476 <pre><code class="language-bash">npm install sax --force
477 </code></pre>
479 <p>See the <a href="../using-npm/config.html"><code>config</code></a> help doc. Many of the config…
483 <h4 id="save"><code>save</code></h4>
485 <li>Default: <code>true</code> unless when using <code>npm update</code> where it defaults to <code…
488 <p>Save installed packages to a <code>package.json</code> file as dependencies.</p>
489 <p>When used with the <code>npm rm</code> command, removes the dependency from
490 <code>package.json</code>.</p>
491 <p>Will also prevent writing to <code>package-lock.json</code> if set to <code>false</code>.</p>
492 <h4 id="save-exact"><code>save-exact</code></h4>
499 <h4 id="global"><code>global</code></h4>
504 <p>Operates in "global" mode, so that packages are installed into the <code>prefix</code>
508 <li>packages are installed into the <code>{prefix}/lib/node_modules</code> folder, instead
510 <li>bin files are linked to <code>{prefix}/bin</code></li>
511 <li>man pages are linked to <code>{prefix}/share/man</code></li>
513 <h4 id="install-strategy"><code>install-strategy</code></h4>
524 <h4 id="legacy-bundling"><code>legacy-bundling</code></h4>
529 <code>--install-strategy=nested</code></li>
531 <p>Instead of hoisting package installs in <code>node_modules</code>, install packages in
534 de-duplicating. Sets <code>--install-strategy=nested</code>.</p>
535 <h4 id="global-style"><code>global-style</code></h4>
540 <code>--install-strategy=shallow</code></li>
542 <p>Only install direct dependencies in the top level <code>node_modules</code>, but hoist
543 on deeper dependencies. Sets <code>--install-strategy=shallow</code>.</p>
544 <h4 id="omit"><code>omit</code></h4>
546 <li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
552 <code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
554 <p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
556 <p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environme…
557 variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
558 <h4 id="include"><code>include</code></h4>
564 <p>This is the inverse of <code>--omit=<type></code>.</p>
565 <p>Dependency types specified in <code>--include</code> will not be omitted, regardless of
567 <h4 id="strict-peer-deps"><code>strict-peer-deps</code></h4>
572 <p>If set to <code>true</code>, and <code>--legacy-peer-deps</code> is not set, then <em>any</em>
573 conflicting <code>peerDependencies</code> will be treated as an install failure, even
576 <p>By default, conflicting <code>peerDependencies</code> deep in the dependency graph will
579 the range set in their package's <code>peerDependencies</code> object.</p>
581 conflict and the packages involved. If <code>--strict-peer-deps</code> is set, then
583 <h4 id="prefer-dedupe"><code>prefer-dedupe</code></h4>
590 <h4 id="package-lock"><code>package-lock</code></h4>
595 <p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
596 will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
597 <h4 id="package-lock-only"><code>package-lock-only</code></h4>
602 <p>If set to true, the current operation will only use the <code>package-lock.json</code>,
603 ignoring <code>node_modules</code>.</p>
604 <p>For <code>update</code> this means only the <code>package-lock.json</code> will be updated,
605 instead of checking <code>node_modules</code> and downloading dependencies.</p>
606 <p>For <code>list</code> this means the output will be based on the tree described by the
607 <code>package-lock.json</code>, rather than the contents of <code>node_modules</code>.</p>
608 <h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
610 <li>Default: <code>false</code> unless when using <code>npm pack</code> or <code>npm publish</code>…
611 defaults to <code>true</code></li>
614 <p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall<…
619 <h4 id="ignore-scripts"><code>ignore-scripts</code></h4>
626 <code>npm start</code>, <code>npm stop</code>, <code>npm restart</code>, <code>npm test</code>, and…
627 will still run their intended script if <code>ignore-scripts</code> is set, but they
629 <h4 id="audit"><code>audit</code></h4>
636 documentation for <a href="../commands/npm-audit.html"><code>npm audit</code></a> for details on wh…
638 <h4 id="bin-links"><code>bin-links</code></h4>
643 <p>Tells npm to create symlinks (or <code>.cmd</code> shims on Windows) for package
648 <h4 id="fund"><code>fund</code></h4>
653 <p>When "true" displays the message at the end of each <code>npm install</code>
654 …cies looking for funding. See <a href="../commands/npm-fund.html"><code>npm fund</code></a> for de…
655 <h4 id="dry-run"><code>dry-run</code></h4>
662 commands that modify your local installation, eg, <code>install</code>, <code>update</code>,
663 <code>dedupe</code>, <code>uninstall</code>, as well as <code>pack</code> and <code>publish</code>.…
664 <p>Note: This is NOT honored by other network related commands, eg <code>dist-tags</code>,
665 <code>owner</code>, etc.</p>
666 <h4 id="cpu"><code>cpu</code></h4>
672 are same as <code>cpu</code> field of package.json, which comes from <code>process.arch</code>.</p>
673 <h4 id="os"><code>os</code></h4>
678 <p>Override OS of native modules to install. Acceptable values are same as <code>os</code>
679 field of package.json, which comes from <code>process.platform</code>.</p>
680 <h4 id="libc"><code>libc</code></h4>
686 <code>libc</code> field of package.json</p>
687 <h4 id="workspace"><code>workspace</code></h4>
695 <p>Valid values for the <code>workspace</code> config are either:</p>
702 <p>When set for the <code>npm init</code> command, this may be set to the folder of a
706 <h4 id="workspaces"><code>workspaces</code></h4>
713 <p>Explicitly setting this to false will cause commands like <code>install</code> to
716 <li>Commands that operate on the <code>node_modules</code> tree (install, update, etc.)
717 will link workspaces into the <code>node_modules</code> folder. - Commands that do
719 <em>unless</em> one or more workspaces are specified in the <code>workspace</code> config.</li>
722 <h4 id="include-workspace-root"><code>include-workspace-root</code></h4>
728 <p>When false, specifying individual workspaces via the <code>workspace</code> config, or
729 all workspaces via the <code>workspaces</code> flag, will cause npm to operate only on
732 <h4 id="install-links"><code>install-links</code></h4>
741 <p>Given a <code>package{dep}</code> structure: <code>A{B,C}, B{C}, C{D}</code>,
743 <pre><code class="language-bash">A
747 </code></pre>
751 <p>For <code>A{B,C}, B{C,D@1}, C{D@2}</code>, this algorithm produces:</p>
752 <pre><code class="language-bash">A
757 </code></pre>