2021-05-10 17:31:02 -04:00
|
|
|
.TH "NPM\-INSTALL" "1" "May 2021" "" ""
|
2011-11-26 09:21:03 -08:00
|
|
|
.SH "NAME"
|
2019-11-18 21:01:39 +02:00
|
|
|
\fBnpm-install\fR \- Install a package
|
2019-11-05 14:55:08 -05:00
|
|
|
.SS Synopsis
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2015-10-09 23:13:57 -07:00
|
|
|
npm install (with no args, in package dir)
|
|
|
|
npm install [<@scope>/]<name>
|
|
|
|
npm install [<@scope>/]<name>@<tag>
|
|
|
|
npm install [<@scope>/]<name>@<version>
|
|
|
|
npm install [<@scope>/]<name>@<version range>
|
2019-11-18 21:01:39 +02:00
|
|
|
npm install <alias>@npm:<name>
|
2017-05-28 21:04:08 -07:00
|
|
|
npm install <git\-host>:<git\-user>/<repo\-name>
|
|
|
|
npm install <git repo url>
|
2011-11-26 09:21:03 -08:00
|
|
|
npm install <tarball file>
|
|
|
|
npm install <tarball url>
|
|
|
|
npm install <folder>
|
2015-10-09 23:13:57 -07:00
|
|
|
|
2019-04-05 15:17:30 -04:00
|
|
|
aliases: npm i, npm add
|
2020-10-20 17:02:27 -04:00
|
|
|
common options: [\-P|\-\-save\-prod|\-D|\-\-save\-dev|\-O|\-\-save\-optional|\-\-save\-peer] [\-E|\-\-save\-exact] [\-B|\-\-save\-bundle] [\-\-no\-save] [\-\-dry\-run]
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
2019-11-05 14:55:08 -05:00
|
|
|
.SS Description
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
2020-10-13 12:42:55 -04:00
|
|
|
This command installs a package and any packages that it depends on\. If the
|
2020-11-01 07:54:36 +01:00
|
|
|
package has a package\-lock, or an npm shrinkwrap file, or a yarn lock file,
|
|
|
|
the installation of dependencies will be driven by that, respecting the
|
|
|
|
following order of precedence:
|
2020-10-13 12:42:55 -04:00
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBnpm\-shrinkwrap\.json\fP
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBpackage\-lock\.json\fP
|
|
|
|
.IP \(bu 2
|
|
|
|
\fByarn\.lock\fP
|
|
|
|
|
|
|
|
.RE
|
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
See npm help package\-lock\.json and
|
|
|
|
npm help \fBshrinkwrap\fP\|\.
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2015-07-24 15:09:52 -07:00
|
|
|
A \fBpackage\fP is:
|
2014-09-24 14:41:07 -07:00
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
a) a folder containing a program described by a
|
|
|
|
npm help \fBpackage\.json\fP file
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2011-11-26 09:21:03 -08:00
|
|
|
b) a gzipped tarball containing (a)
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2011-11-26 09:21:03 -08:00
|
|
|
c) a url that resolves to (b)
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
d) a \fB<name>@<version>\fP that is published on the registry (see
|
|
|
|
npm help \fBregistry\fP) with (c)
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
e) a \fB<name>@<tag>\fP (see npm help \fBdist\-tag\fP) that
|
|
|
|
points to (d)
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
f) a \fB<name>\fP that has a "latest" tag satisfying (e)
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2015-10-09 23:13:57 -07:00
|
|
|
g) a \fB<git remote url>\fP that resolves to (a)
|
2014-09-24 14:41:07 -07:00
|
|
|
|
|
|
|
.RE
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
Even if you never publish your package, you can still get a lot of benefits
|
|
|
|
of using npm if you just want to write a node program (a), and perhaps if
|
|
|
|
you also want to be able to easily install it elsewhere after packing it up
|
|
|
|
into a tarball (b)\.
|
2014-09-24 14:41:07 -07:00
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
2020-10-13 12:42:55 -04:00
|
|
|
\fBnpm install\fP (in a package directory, no arguments):
|
|
|
|
Install the dependencies in the local \fBnode_modules\fP folder\.
|
2015-07-24 15:09:52 -07:00
|
|
|
In global mode (ie, with \fB\-g\fP or \fB\-\-global\fP appended to the command),
|
2014-09-24 14:41:07 -07:00
|
|
|
it installs the current package context (ie, the current working
|
|
|
|
directory) as a global package\.
|
2020-11-01 07:54:36 +01:00
|
|
|
By default, \fBnpm install\fP will install all modules listed as
|
|
|
|
dependencies in npm help \fBpackage\.json\fP\|\.
|
|
|
|
With the \fB\-\-production\fP flag (or when the \fBNODE_ENV\fP environment
|
|
|
|
variable is set to \fBproduction\fP), npm will not install modules listed
|
|
|
|
in \fBdevDependencies\fP\|\. To install all modules listed in both
|
|
|
|
\fBdependencies\fP and \fBdevDependencies\fP when \fBNODE_ENV\fP environment
|
|
|
|
variable is set to \fBproduction\fP, you can use \fB\-\-production=false\fP\|\.
|
2018-04-20 18:26:37 -07:00
|
|
|
.QP
|
|
|
|
NOTE: The \fB\-\-production\fP flag has no particular meaning when adding a
|
|
|
|
dependency to a project\.
|
|
|
|
|
|
|
|
.
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install <folder>\fP:
|
2020-11-01 07:54:36 +01:00
|
|
|
Install the package in the directory as a symlink in the current
|
|
|
|
project\. Its dependencies will be installed before it's linked\. If
|
|
|
|
\fB<folder>\fP sits inside the root of your project, its dependencies may
|
|
|
|
be hoisted to the top\-level \fBnode_modules\fP as they would for other
|
|
|
|
types of dependencies\.
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install <tarball file>\fP:
|
2020-11-01 07:54:36 +01:00
|
|
|
Install a package that is sitting on the filesystem\. Note: if you just
|
|
|
|
want to link a dev directory into your npm root, you can do this more
|
|
|
|
easily by using npm help \fBlink\fP\|\.
|
2018-07-18 13:55:52 -07:00
|
|
|
Tarball requirements:
|
2019-07-24 23:00:03 -07:00
|
|
|
.RS
|
2018-07-18 13:55:52 -07:00
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
The filename \fImust\fR use \fB\|\.tar\fP, \fB\|\.tar\.gz\fP, or \fB\|\.tgz\fP as the
|
|
|
|
extension\.
|
2018-07-18 13:55:52 -07:00
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
The package contents should reside in a subfolder inside the tarball
|
|
|
|
(usually it is called \fBpackage/\fP)\. npm strips one directory layer
|
|
|
|
when installing the package (an equivalent of \fBtar x
|
|
|
|
\-\-strip\-components=1\fP is run)\.
|
2018-07-18 13:55:52 -07:00
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
The package must contain a \fBpackage\.json\fP file with \fBname\fP and
|
|
|
|
\fBversion\fP properties\.
|
2018-07-18 13:55:52 -07:00
|
|
|
Example:
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2018-07-18 13:55:52 -07:00
|
|
|
npm install \./package\.tgz
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2018-07-18 13:55:52 -07:00
|
|
|
.RE
|
|
|
|
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install <tarball url>\fP:
|
2014-09-24 14:41:07 -07:00
|
|
|
Fetch the tarball url, and then install it\. In order to distinguish between
|
|
|
|
this and other options, the argument must start with "http://" or "https://"
|
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2020-11-01 07:54:36 +01:00
|
|
|
npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2017-05-28 21:04:08 -07:00
|
|
|
\fBnpm install [<@scope>/]<name>\fP:
|
2015-07-24 15:09:52 -07:00
|
|
|
Do a \fB<name>@<tag>\fP install, where \fB<tag>\fP is the "tag" config\. (See
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help \fBconfig\fP\|\. The config's default value is \fBlatest\fP\|\.)
|
2017-05-28 21:04:08 -07:00
|
|
|
In most cases, this will install the version of the modules tagged as
|
|
|
|
\fBlatest\fP on the npm registry\.
|
2014-09-24 14:41:07 -07:00
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2020-11-01 07:54:36 +01:00
|
|
|
npm install sax
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
2020-10-13 12:42:55 -04:00
|
|
|
\fBnpm install\fP saves any specified packages into \fBdependencies\fP by default\.
|
|
|
|
Additionally, you can control where and how they get saved with some
|
|
|
|
additional flags:
|
|
|
|
.RS
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
\fB\-P, \-\-save\-prod\fP: Package will appear in your \fBdependencies\fP\|\. This
|
|
|
|
is the default unless \fB\-D\fP or \fB\-O\fP are present\.
|
2020-10-13 12:42:55 -04:00
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-D, \-\-save\-dev\fP: Package will appear in your \fBdevDependencies\fP\|\.
|
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
\fB\-O, \-\-save\-optional\fP: Package will appear in your
|
|
|
|
\fBoptionalDependencies\fP\|\.
|
2020-10-13 12:42:55 -04:00
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-no\-save\fP: Prevents saving to \fBdependencies\fP\|\.
|
2014-03-19 09:25:40 -07:00
|
|
|
When using any of the above options to save dependencies to your
|
2016-03-29 23:30:51 -07:00
|
|
|
package\.json, there are two additional, optional flags:
|
2020-10-13 12:42:55 -04:00
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-E, \-\-save\-exact\fP: Saved dependencies will be configured with an
|
2020-11-01 07:54:36 +01:00
|
|
|
exact version rather than using npm's default semver range operator\.
|
2020-10-13 12:42:55 -04:00
|
|
|
.IP \(bu 2
|
2020-11-01 07:54:36 +01:00
|
|
|
\fB\-B, \-\-save\-bundle\fP: Saved dependencies will also be added to your
|
|
|
|
\fBbundleDependencies\fP list\.
|
|
|
|
Further, if you have an \fBnpm\-shrinkwrap\.json\fP or \fBpackage\-lock\.json\fP
|
|
|
|
then it will be updated as well\.
|
2020-10-13 12:42:55 -04:00
|
|
|
\fB<scope>\fP is optional\. The package will be downloaded from the registry
|
2014-09-24 14:41:07 -07:00
|
|
|
associated with the specified scope\. If no registry is associated with
|
2020-11-01 07:54:36 +01:00
|
|
|
the given scope the default registry is assumed\. See
|
|
|
|
npm help \fBscope\fP\|\.
|
2014-09-24 14:41:07 -07:00
|
|
|
Note: if you do not include the @\-symbol on your scope name, npm will
|
|
|
|
interpret this as a GitHub repository instead, see below\. Scopes names
|
|
|
|
must also be followed by a slash\.
|
2012-05-05 22:33:06 -07:00
|
|
|
Examples:
|
2020-10-13 12:42:55 -04:00
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
2017-05-28 21:04:08 -07:00
|
|
|
npm install sax
|
2014-09-24 14:41:07 -07:00
|
|
|
npm install githubname/reponame
|
|
|
|
npm install @myorg/privatepackage
|
|
|
|
npm install node\-tap \-\-save\-dev
|
|
|
|
npm install dtrace\-provider \-\-save\-optional
|
2017-05-28 21:04:08 -07:00
|
|
|
npm install readable\-stream \-\-save\-exact
|
|
|
|
npm install ansi\-regex \-\-save\-bundle
|
2020-10-13 12:42:55 -04:00
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
|
|
|
\fINote*\fR: If there is a file or folder named \fB<name>\fP in the current
|
2014-09-24 14:41:07 -07:00
|
|
|
working directory, then it will try to install that, and only try to
|
|
|
|
fetch the package by name if it is not valid\.
|
2020-10-13 12:42:55 -04:00
|
|
|
|
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBnpm install <alias>@npm:<name>\fP:
|
|
|
|
Install a package under a custom alias\. Allows multiple versions of
|
|
|
|
a same\-name package side\-by\-side, more convenient import names for
|
|
|
|
packages with otherwise long ones, and using git forks replacements
|
|
|
|
or forked npm packages as replacements\. Aliasing works only on your
|
|
|
|
project and does not rename packages in transitive dependencies\.
|
|
|
|
Aliases should follow the naming conventions stated in
|
|
|
|
\fBvalidate\-npm\-package\-name\fP \fIhttps://www\.npmjs\.com/package/validate\-npm\-package\-name#naming\-rules\fR\|\.
|
|
|
|
Examples:
|
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
2020-11-01 07:54:36 +01:00
|
|
|
npm install my\-react@npm:react
|
|
|
|
npm install jquery2@npm:jquery@2
|
|
|
|
npm install jquery3@npm:jquery@3
|
|
|
|
npm install npa@npm:npm\-package\-arg
|
2019-11-18 21:01:39 +02:00
|
|
|
.fi
|
2020-10-13 12:42:55 -04:00
|
|
|
.RE
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2015-10-09 23:13:57 -07:00
|
|
|
\fBnpm install [<@scope>/]<name>@<tag>\fP:
|
2014-09-24 14:41:07 -07:00
|
|
|
Install the version of the package that is referenced by the specified tag\.
|
|
|
|
If the tag does not exist in the registry data for that package, then this
|
|
|
|
will fail\.
|
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2019-11-05 14:55:08 -05:00
|
|
|
npm install sax@latest
|
|
|
|
npm install @myorg/mypackage@latest
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2015-10-09 23:13:57 -07:00
|
|
|
\fBnpm install [<@scope>/]<name>@<version>\fP:
|
2014-09-24 14:41:07 -07:00
|
|
|
Install the specified version of the package\. This will fail if the
|
|
|
|
version has not been published to the registry\.
|
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2019-11-05 14:55:08 -05:00
|
|
|
npm install sax@0\.1\.1
|
|
|
|
npm install @myorg/privatepackage@1\.5\.0
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2015-10-09 23:13:57 -07:00
|
|
|
\fBnpm install [<@scope>/]<name>@<version range>\fP:
|
2020-11-01 07:54:36 +01:00
|
|
|
Install a version of the package matching the specified version range\.
|
|
|
|
This will follow the same rules for resolving dependencies described in
|
|
|
|
npm help \fBpackage\.json\fP\|\.
|
|
|
|
Note that most version ranges must be put in quotes so that your shell
|
|
|
|
will treat it as a single argument\.
|
2014-09-24 14:41:07 -07:00
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2019-11-05 14:55:08 -05:00
|
|
|
npm install sax@">=0\.1\.0 <0\.2\.0"
|
2020-10-13 12:42:55 -04:00
|
|
|
npm install @myorg/privatepackage@"16 \- 17"
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install <git remote url>\fP:
|
2020-11-01 07:54:36 +01:00
|
|
|
Installs the package from the hosted git provider, cloning it with
|
|
|
|
\fBgit\fP\|\. For a full git remote url, only that URL will be attempted\.
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2020-11-01 07:54:36 +01:00
|
|
|
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit\-ish> | #semver:<semver>]
|
2015-05-22 03:14:39 -04:00
|
|
|
.fi
|
|
|
|
.RE
|
2017-05-28 21:04:08 -07:00
|
|
|
\fB<protocol>\fP is one of \fBgit\fP, \fBgit+ssh\fP, \fBgit+http\fP, \fBgit+https\fP, or
|
|
|
|
\fBgit+file\fP\|\.
|
|
|
|
If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
|
2020-11-01 07:54:36 +01:00
|
|
|
commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP
|
|
|
|
can be any valid semver range or exact version, and npm will look for
|
|
|
|
any tags or refs matching that range in the remote repository, much as
|
|
|
|
it would for a registry dependency\. If neither \fB#<commit\-ish>\fP or
|
|
|
|
\fB#semver:<semver>\fP is specified, then the default branch of the
|
|
|
|
repository is used\.
|
|
|
|
If the repository makes use of submodules, those submodules will be
|
|
|
|
cloned as well\.
|
2017-05-28 21:04:08 -07:00
|
|
|
If the package being installed contains a \fBprepare\fP script, its
|
|
|
|
\fBdependencies\fP and \fBdevDependencies\fP will be installed, and the prepare
|
|
|
|
script will be run, before the package is packaged and installed\.
|
2020-11-01 07:54:36 +01:00
|
|
|
The following git environment variables are recognized by npm and will
|
|
|
|
be added to the environment when running git:
|
2019-07-24 23:00:03 -07:00
|
|
|
.RS
|
2015-07-06 00:00:48 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBGIT_ASKPASS\fP
|
2015-07-06 00:00:48 -07:00
|
|
|
.IP \(bu 2
|
2016-09-22 07:59:37 -07:00
|
|
|
\fBGIT_EXEC_PATH\fP
|
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBGIT_PROXY_COMMAND\fP
|
2015-07-06 00:00:48 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBGIT_SSH\fP
|
2015-07-06 00:00:48 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBGIT_SSH_COMMAND\fP
|
2015-07-06 00:00:48 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBGIT_SSL_CAINFO\fP
|
2015-07-06 00:00:48 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBGIT_SSL_NO_VERIFY\fP
|
2015-07-06 00:00:48 -07:00
|
|
|
See the git man page for details\.
|
|
|
|
Examples:
|
2015-05-22 03:14:39 -04:00
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
2018-07-18 13:55:52 -07:00
|
|
|
npm install git+ssh://git@github\.com:npm/cli\.git#v1\.0\.27
|
2020-10-13 12:42:55 -04:00
|
|
|
npm install git+ssh://git@github\.com:npm/cli#pull/273
|
2018-07-18 13:55:52 -07:00
|
|
|
npm install git+ssh://git@github\.com:npm/cli#semver:^5\.0
|
|
|
|
npm install git+https://isaacs@github\.com/npm/cli\.git
|
|
|
|
npm install git://github\.com/npm/cli\.git#v1\.0\.27
|
|
|
|
GIT_SSH_COMMAND='ssh \-i ~/\.ssh/custom_ident' npm install git+ssh://git@github\.com:npm/cli\.git
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2015-07-06 00:00:48 -07:00
|
|
|
.RE
|
|
|
|
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
2015-04-17 01:12:21 -07:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install <githubname>/<githubrepo>[#<commit\-ish>]\fP:
|
2015-05-22 03:14:39 -04:00
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install github:<githubname>/<githubrepo>[#<commit\-ish>]\fP:
|
|
|
|
Install the package at \fBhttps://github\.com/githubname/githubrepo\fP by
|
|
|
|
attempting to clone it using \fBgit\fP\|\.
|
2017-05-28 21:04:08 -07:00
|
|
|
If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
|
2020-11-01 07:54:36 +01:00
|
|
|
commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP
|
|
|
|
can be any valid semver range or exact version, and npm will look for
|
|
|
|
any tags or refs matching that range in the remote repository, much as
|
|
|
|
it would for a registry dependency\. If neither \fB#<commit\-ish>\fP or
|
|
|
|
\fB#semver:<semver>\fP is specified, then \fBmaster\fP is used\.
|
|
|
|
As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP
|
|
|
|
will be installed if the package has a \fBprepare\fP script before the
|
|
|
|
package is done installing\.
|
2015-05-22 03:14:39 -04:00
|
|
|
Examples:
|
2015-04-17 01:12:21 -07:00
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
2019-11-05 14:55:08 -05:00
|
|
|
npm install mygithubuser/myproject
|
|
|
|
npm install github:mygithubuser/myproject
|
2015-04-17 01:12:21 -07:00
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2017-05-28 21:04:08 -07:00
|
|
|
\fBnpm install gist:[<githubname>/]<gistID>[#<commit\-ish>|#semver:<semver>]\fP:
|
2015-07-24 15:09:52 -07:00
|
|
|
Install the package at \fBhttps://gist\.github\.com/gistID\fP by attempting to
|
|
|
|
clone it using \fBgit\fP\|\. The GitHub username associated with the gist is
|
2017-05-28 21:04:08 -07:00
|
|
|
optional and will not be saved in \fBpackage\.json\fP\|\.
|
|
|
|
As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP will
|
2020-10-13 12:42:55 -04:00
|
|
|
be installed if the package has a \fBprepare\fP script before the package is
|
2017-05-28 21:04:08 -07:00
|
|
|
done installing\.
|
2015-04-17 01:12:21 -07:00
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
2019-11-05 14:55:08 -05:00
|
|
|
npm install gist:101a11beef
|
2015-04-17 01:12:21 -07:00
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit\-ish>]\fP:
|
|
|
|
Install the package at \fBhttps://bitbucket\.org/bitbucketname/bitbucketrepo\fP
|
|
|
|
by attempting to clone it using \fBgit\fP\|\.
|
2017-05-28 21:04:08 -07:00
|
|
|
If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
|
|
|
|
commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP can
|
|
|
|
be any valid semver range or exact version, and npm will look for any tags
|
|
|
|
or refs matching that range in the remote repository, much as it would for a
|
|
|
|
registry dependency\. If neither \fB#<commit\-ish>\fP or \fB#semver:<semver>\fP is
|
|
|
|
specified, then \fBmaster\fP is used\.
|
|
|
|
As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP will
|
2020-10-13 12:42:55 -04:00
|
|
|
be installed if the package has a \fBprepare\fP script before the package is
|
2017-05-28 21:04:08 -07:00
|
|
|
done installing\.
|
2015-04-17 01:12:21 -07:00
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
2019-11-05 14:55:08 -05:00
|
|
|
npm install bitbucket:mybitbucketuser/myproject
|
2015-04-17 01:12:21 -07:00
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
.IP \(bu 2
|
2015-07-24 15:09:52 -07:00
|
|
|
\fBnpm install gitlab:<gitlabname>/<gitlabrepo>[#<commit\-ish>]\fP:
|
|
|
|
Install the package at \fBhttps://gitlab\.com/gitlabname/gitlabrepo\fP
|
|
|
|
by attempting to clone it using \fBgit\fP\|\.
|
2017-05-28 21:04:08 -07:00
|
|
|
If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
|
|
|
|
commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP can
|
|
|
|
be any valid semver range or exact version, and npm will look for any tags
|
|
|
|
or refs matching that range in the remote repository, much as it would for a
|
|
|
|
registry dependency\. If neither \fB#<commit\-ish>\fP or \fB#semver:<semver>\fP is
|
|
|
|
specified, then \fBmaster\fP is used\.
|
|
|
|
As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP will
|
2020-10-13 12:42:55 -04:00
|
|
|
be installed if the package has a \fBprepare\fP script before the package is
|
2017-05-28 21:04:08 -07:00
|
|
|
done installing\.
|
2015-04-17 01:12:21 -07:00
|
|
|
Example:
|
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
2019-11-05 14:55:08 -05:00
|
|
|
npm install gitlab:mygitlabuser/myproject
|
|
|
|
npm install gitlab:myusr/myproj#semver:^5\.0
|
2015-04-17 01:12:21 -07:00
|
|
|
.fi
|
|
|
|
.RE
|
2011-11-26 09:21:03 -08:00
|
|
|
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2020-10-13 12:42:55 -04:00
|
|
|
You may combine multiple arguments and even multiple types of arguments\.
|
2011-11-26 09:21:03 -08:00
|
|
|
For example:
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2011-11-26 09:21:03 -08:00
|
|
|
npm install sax@">=0\.1\.0 <0\.2\.0" bench supervisor
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
The \fB\-\-tag\fP argument will apply to all of the specified install targets\. If
|
|
|
|
a tag with the given name exists, the tagged version is preferred over
|
|
|
|
newer versions\.
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
The \fB\-\-dry\-run\fP argument will report in the usual way what the install
|
|
|
|
would have done without actually installing anything\.
|
2015-10-09 23:13:57 -07:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
The \fB\-\-package\-lock\-only\fP argument will only update the
|
|
|
|
\fBpackage\-lock\.json\fP, instead of checking \fBnode_modules\fP and downloading
|
|
|
|
dependencies\.
|
2017-12-07 14:05:23 -08:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
The \fB\-f\fP or \fB\-\-force\fP argument will force npm to fetch remote resources
|
|
|
|
even if a local copy exists on disk\.
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2011-11-26 09:21:03 -08:00
|
|
|
npm install sax \-\-force
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
2020-11-01 07:54:36 +01:00
|
|
|
.SS Configuration
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
See the npm help \fBconfig\fP help doc\. Many of the configuration
|
|
|
|
params have some effect on installation, since that's most of what npm
|
|
|
|
does\.
|
2020-10-13 12:42:55 -04:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
These are some of the most common options related to installation\.
|
|
|
|
.SS Configuration Options Affecting Dependency Resolution And Tree Design
|
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-g\fP or \fB\-\-global\fP: install the package globally rather than locally\.
|
|
|
|
See npm help folders\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-global\-style\fP: install the package into your local \fBnode_modules\fP
|
|
|
|
folder with the same layout it uses with the global \fBnode_modules\fP
|
|
|
|
folder\. Only your direct dependencies will show in \fBnode_modules\fP and
|
|
|
|
everything they depend on will be flattened in their \fBnode_modules\fP
|
|
|
|
folders\. This obviously will eliminate some deduping\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-legacy\-bundling\fP: install the package in the style of versions of npm
|
|
|
|
prior to 1\.4, where dependencies are not automatically deduped up to the
|
|
|
|
shallowest level in the tree possible\. This is extremely
|
|
|
|
disk\-inefficient\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-legacy\-peer\-deps\fP: ignore all \fBpeerDependencies\fP when installing, in
|
|
|
|
the style of npm version 4 through version 6\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-strict\-peer\-deps\fP: fail and abort the install process for any
|
|
|
|
conflicting peerDependencies when encountered\. By default, npm will only
|
|
|
|
crash for peerDependencies conflicts caused by the direct dependencies of
|
|
|
|
the root project\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-no\-package\-lock\fP (alias: \fB\-\-no\-shrinkwrap\fP): do not read the
|
|
|
|
lockfile (\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP) for the intended
|
|
|
|
package tree, and do not save the resulting package tree back to a
|
|
|
|
lockfile\.
|
|
|
|
|
|
|
|
.RE
|
|
|
|
.SS Omitting Dependency Types
|
2013-06-04 11:42:32 -07:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
You may omit certain types of dependencies by using the \fB\-\-omit=<type>\fP
|
|
|
|
config option\. This may be specified multiple types on the command line\.
|
|
|
|
To enter \fBomit\fP options in \fB\|\.npmrc\fP files, use the following syntax:
|
2017-07-14 10:52:48 -07:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
.RS 2
|
|
|
|
.nf
|
|
|
|
omit[] = dev
|
|
|
|
omit[] = optional
|
|
|
|
; etc\.\.\.
|
|
|
|
.fi
|
|
|
|
.RE
|
2013-06-04 11:42:32 -07:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
The dependency types that may be omitted or included are:
|
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBpeer\fP: any \fBpeerDependencies\fP, including those with a
|
|
|
|
\fBpeerDependenciesMeta\fP entry specifying \fBoptional: true\fP
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBoptional\fP: dependencies listed in \fBoptionalDependencies\fP
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBdev\fP: dependencies listed in \fBdevDependencies\fP
|
|
|
|
|
|
|
|
.RE
|
2015-10-09 23:13:57 -07:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
To re\-include dependency, use the \fB\-\-include\fP option, which may also be
|
|
|
|
specified multiple times\.
|
2018-04-20 18:26:37 -07:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
Legacy shorthands for \fBomit\fP settings are:
|
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-no\-optional\fP: prevent optionalDependencies from being installed\. Note
|
|
|
|
that their presence is still entered in the \fBpackage\-lock\.json\fP file, and
|
|
|
|
the tree is designed such that they \fIcan\fR be installed in the future\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-prod\fP: prevent devDependencies from being installed\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-only=prod\fP: omit \fBdevDependencies\fP
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-also=dev\fP: include \fBdevDependencies\fP
|
|
|
|
|
|
|
|
.RE
|
|
|
|
.SS Configuration Options Affecting Build Process
|
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-ignore\-scripts\fP: do not execute any scripts defined in the
|
|
|
|
package\.json\. See npm help \fBscripts\fP\|\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-no\-audit\fP: disable sending audit reports to the configured registries\.
|
|
|
|
See \fBnpm\-audit\fP \fInpm\-audit\fR for details on what is sent\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-no\-bin\-links\fP: prevent npm from creating symlinks for any binaries the
|
|
|
|
package might contain\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-no\-fund\fP: suppress the message displayed at the end of each install
|
|
|
|
that acknowledges the number of dependencies looking for funding\. See
|
|
|
|
npm help \fBnpm\-fund\fP
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-dry\-run\fP: Do not actually install anything into the \fBnode_modules\fP
|
|
|
|
folder\. Just build the intended tree in memory, and report on it\.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB\-\-no\-save\fP: Do not save installed dependencies to \fBpackage\.json\fP or
|
|
|
|
\fBpackage\-lock\.json\fP\|\.
|
|
|
|
|
|
|
|
.RE
|
2019-11-05 14:55:08 -05:00
|
|
|
.SS Algorithm
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
2020-10-13 12:42:55 -04:00
|
|
|
Given a \fBpackage{dep}\fP structure: \fBA{B,C}, B{C}, C{D}\fP,
|
|
|
|
the npm install algorithm produces:
|
2014-09-24 14:41:07 -07:00
|
|
|
.P
|
|
|
|
.RS 2
|
2014-11-04 15:08:12 -08:00
|
|
|
.nf
|
2011-11-26 09:21:03 -08:00
|
|
|
A
|
|
|
|
+\-\- B
|
2015-10-09 23:13:57 -07:00
|
|
|
+\-\- C
|
|
|
|
+\-\- D
|
2014-11-04 15:08:12 -08:00
|
|
|
.fi
|
2014-09-24 14:41:07 -07:00
|
|
|
.RE
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
That is, the dependency from B to C is satisfied by the fact that A already
|
|
|
|
caused C to be installed at a higher level\. D is still installed at the top
|
|
|
|
level because nothing conflicts with it\.
|
2015-10-09 23:13:57 -07:00
|
|
|
.P
|
|
|
|
For \fBA{B,C}, B{C,D@1}, C{D@2}\fP, this algorithm produces:
|
|
|
|
.P
|
|
|
|
.RS 2
|
|
|
|
.nf
|
|
|
|
A
|
|
|
|
+\-\- B
|
|
|
|
+\-\- C
|
|
|
|
`\-\- D@2
|
|
|
|
+\-\- D@1
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
Because B's D@1 will be installed in the top\-level, C now has to install
|
|
|
|
D@2 privately for itself\. This algorithm is deterministic, but different
|
|
|
|
trees may be produced if two dependencies are requested for installation in
|
|
|
|
a different order\.
|
2011-11-26 09:21:03 -08:00
|
|
|
.P
|
2020-11-01 07:54:36 +01:00
|
|
|
See npm help folders for a more detailed description of
|
|
|
|
the specific folder structures that npm creates\.
|
2019-11-05 14:55:08 -05:00
|
|
|
.SS See Also
|
2014-09-24 14:41:07 -07:00
|
|
|
.RS 0
|
|
|
|
.IP \(bu 2
|
2019-11-05 14:55:08 -05:00
|
|
|
npm help folders
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help update
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help audit
|
2018-04-20 18:26:37 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help fund
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help link
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help rebuild
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-05 14:55:08 -05:00
|
|
|
npm help scripts
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help config
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-05 14:55:08 -05:00
|
|
|
npm help npmrc
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-05 14:55:08 -05:00
|
|
|
npm help registry
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help dist\-tag
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help uninstall
|
2014-09-24 14:41:07 -07:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help shrinkwrap
|
2016-01-28 18:11:35 -08:00
|
|
|
.IP \(bu 2
|
2019-11-18 21:01:39 +02:00
|
|
|
npm help package\.json
|
2020-10-15 20:32:02 -04:00
|
|
|
.IP \(bu 2
|
|
|
|
npm help workspaces
|
2014-09-24 14:41:07 -07:00
|
|
|
|
|
|
|
.RE
|