This commit is contained in:
marsal wang
2023-07-26 10:07:34 +08:00
parent f884cb1020
commit 1e5a703cce
5384 changed files with 618283 additions and 4002 deletions

View File

@ -0,0 +1,168 @@
.TH "NPM" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm\fR \- a JavaScript package manager
.P
Build Status \fIhttps://img\.shields\.io/travis/npm/cli/latest\.svg\fR \fIhttps://travis\-ci\.org/npm/cli\fR
.SH SYNOPSIS
.P
This is just enough info to get you up and running\.
.P
Much more info will be available via \fBnpm help\fP once it's installed\.
.SH IMPORTANT
.P
\fBYou need node v6 or higher to run this program\.\fR
.P
To install an old \fBand unsupported\fR version of npm that works on node v5
and prior, clone the git repo and dig through the old tags and branches\.
.P
\fBnpm is configured to use npm, Inc\.'s public registry at
https://registry\.npmjs\.org by default\.\fR Use of the npm public registry
is subject to terms of use available at https://www\.npmjs\.com/policies/terms\|\.
.P
You can configure npm to use any compatible registry you
like, and even run your own registry\. Check out the doc on
registries \fIhttps://docs\.npmjs\.com/misc/registry\fR\|\.
.SH Super Easy Install
.P
npm is bundled with node \fIhttps://nodejs\.org/en/download/\fR\|\.
.SS Windows Computers
.P
Get the MSI \fIhttps://nodejs\.org/en/download/\fR\|\. npm is in it\.
.SS Apple Macintosh Computers
.P
Get the pkg \fIhttps://nodejs\.org/en/download/\fR\|\. npm is in it\.
.SS Other Sorts of Unices
.P
Run \fBmake install\fP\|\. npm will be installed with node\.
.P
If you want a more fancy pants install (a different version, customized
paths, etc\.) then read on\.
.SH Fancy Install (Unix)
.P
There's a pretty robust install script at
https://www\.npmjs\.com/install\.sh\|\. You can download that and run it\.
.P
Here's an example using curl:
.P
.RS 2
.nf
curl \-L https://www\.npmjs\.com/install\.sh | sh
.fi
.RE
.SS Slightly Fancier
.P
You can set any npm configuration params with that script:
.P
.RS 2
.nf
npm_config_prefix=/some/path sh install\.sh
.fi
.RE
.P
Or, you can run it in uber\-debuggery mode:
.P
.RS 2
.nf
npm_debug=1 sh install\.sh
.fi
.RE
.SS Even Fancier
.P
Get the code with git\. Use \fBmake\fP to build the docs and do other stuff\.
If you plan on hacking on npm, \fBmake link\fP is your friend\.
.P
If you've got the npm source code, you can also semi\-permanently set
arbitrary config keys using the \fB\|\./configure \-\-key=val \.\.\.\fP, and then
run npm commands by doing \fBnode bin/npm\-cli\.js <command> <args>\fP\|\. (This is helpful
for testing, or running stuff without actually installing npm itself\.)
.SH Windows Install or Upgrade
.P
Many improvements for Windows users have been made in npm 3 \- you will have a better
experience if you run a recent version of npm\. To upgrade, either use Microsoft's
upgrade tool \fIhttps://github\.com/felixrieseberg/npm\-windows\-upgrade\fR,
download a new version of Node \fIhttps://nodejs\.org/en/download/\fR,
or follow the Windows upgrade instructions in the
Installing/upgrading npm \fIhttps://npm\.community/t/installing\-upgrading\-npm/251/2\fR post\.
.P
If that's not fancy enough for you, then you can fetch the code with
git, and mess with it directly\.
.SH Installing on Cygwin
.P
No\.
.SH Uninstalling
.P
So sad to see you go\.
.P
.RS 2
.nf
sudo npm uninstall npm \-g
.fi
.RE
.P
Or, if that fails,
.P
.RS 2
.nf
sudo make uninstall
.fi
.RE
.SH More Severe Uninstalling
.P
Usually, the above instructions are sufficient\. That will remove
npm, but leave behind anything you've installed\.
.P
If you would like to remove all the packages that you have installed,
then you can use the \fBnpm ls\fP command to find them, and then \fBnpm rm\fP to
remove them\.
.P
To remove cruft left behind by npm 0\.x, you can use the included
\fBclean\-old\.sh\fP script file\. You can run it conveniently like this:
.P
.RS 2
.nf
npm explore npm \-g \-\- sh scripts/clean\-old\.sh
.fi
.RE
.P
npm uses two configuration files, one for per\-user configs, and another
for global (every\-user) configs\. You can view them by doing:
.P
.RS 2
.nf
npm config get userconfig # defaults to ~/\.npmrc
npm config get globalconfig # defaults to /usr/local/etc/npmrc
.fi
.RE
.P
Uninstalling npm does not remove configuration files by default\. You
must remove them yourself manually if you want them gone\. Note that
this means that future npm installs will not remember the settings that
you have chosen\.
.SH More Docs
.P
Check out the docs \fIhttps://docs\.npmjs\.com/\fR\|\.
.P
You can use the \fBnpm help\fP command to read any of them\.
.P
If you're a developer, and you want to use npm to publish your program,
you should read this \fIhttps://docs\.npmjs\.com/misc/developers\fR\|\.
.SH BUGS
.P
When you find issues, please report them:
.RS 0
.IP \(bu 2
web:
https://npm\.community/c/bugs
.RE
.P
Be sure to include \fIall\fR of the output from the npm command that didn't work
as expected\. The \fBnpm\-debug\.log\fP file is also helpful to provide\.
.SH SEE ALSO
.RS 0
.IP \(bu 2
npm(1)
.IP \(bu 2
npm\-help(1)
.RE

View File

@ -0,0 +1,100 @@
.TH "NPM\-ACCESS" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-access\fR \- Set access level on published packages
.SS Synopsis
.P
.RS 2
.nf
npm access public [<package>]
npm access restricted [<package>]
npm access grant <read\-only|read\-write> <scope:team> [<package>]
npm access revoke <scope:team> [<package>]
npm access 2fa\-required [<package>]
npm access 2fa\-not\-required [<package>]
npm access ls\-packages [<user>|<scope>|<scope:team>]
npm access ls\-collaborators [<package> [<user>]]
npm access edit [<package>]
.fi
.RE
.SS Description
.P
Used to set access controls on private packages\.
.P
For all of the subcommands, \fBnpm access\fP will perform actions on the packages
in the current working directory if no package name is passed to the
subcommand\.
.RS 0
.IP \(bu 2
public / restricted:
Set a package to be either publicly accessible or restricted\.
.IP \(bu 2
grant / revoke:
Add or remove the ability of users and teams to have read\-only or read\-write
access to a package\.
.IP \(bu 2
2fa\-required / 2fa\-not\-required:
Configure whether a package requires that anyone publishing it have two\-factor
authentication enabled on their account\.
.IP \(bu 2
ls\-packages:
Show all of the packages a user or a team is able to access, along with the
access level, except for read\-only public packages (it won't print the whole
registry listing)
.IP \(bu 2
ls\-collaborators:
Show all of the access privileges for a package\. Will only show permissions
for packages to which you have at least read access\. If \fB<user>\fP is passed in,
the list is filtered only to teams \fIthat\fR user happens to belong to\.
.IP \(bu 2
edit:
Set the access privileges for a package at once using \fB$EDITOR\fP\|\.
.RE
.SS Details
.P
\fBnpm access\fP always operates directly on the current registry, configurable
from the command line using \fB\-\-registry=<registry url>\fP\|\.
.P
Unscoped packages are \fIalways public\fR\|\.
.P
Scoped packages \fIdefault to restricted\fR, but you can either publish them as
public using \fBnpm publish \-\-access=public\fP, or set their access as public using
\fBnpm access public\fP after the initial publish\.
.P
You must have privileges to set the access of a package:
.RS 0
.IP \(bu 2
You are an owner of an unscoped or scoped package\.
.IP \(bu 2
You are a member of the team that owns a scope\.
.IP \(bu 2
You have been given read\-write privileges for a package, either as a member
of a team or directly as an owner\.
.RE
.P
If you have two\-factor authentication enabled then you'll have to pass in an
otp with \fB\-\-otp\fP when making access changes\.
.P
If your account is not paid, then attempts to publish scoped packages will fail
with an HTTP 402 status code (logically enough), unless you use
\fB\-\-access=public\fP\|\.
.P
Management of teams and team memberships is done with the \fBnpm team\fP command\.
.SS See Also
.RS 0
.IP \(bu 2
\fBlibnpmaccess\fP \fIhttps://npm\.im/libnpmaccess\fR
.IP \(bu 2
npm help team
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help config
.IP \(bu 2
npm help registry
.RE

View File

@ -0,0 +1,104 @@
.HR
.P
section: cli\-commands
title: npm\-adduser
description: Set access level on published packages
.HR
.TH "NPM\-ADDUSER" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-adduser\fR \- Add a registry user account
.SS Synopsis
.P
.RS 2
.nf
npm adduser [\-\-registry=url] [\-\-scope=@orgname] [\-\-always\-auth] [\-\-auth\-type=legacy]
aliases: login, add\-user
.fi
.RE
.SS Description
.P
Create or verify a user named \fB<username>\fP in the specified registry, and
save the credentials to the \fB\|\.npmrc\fP file\. If no registry is specified,
the default registry will be used (see npm help \fBconfig\fP)\.
.P
The username, password, and email are read in from prompts\.
.P
To reset your password, go to https://www\.npmjs\.com/forgot
.P
To change your email address, go to https://www\.npmjs\.com/email\-edit
.P
You may use this command multiple times with the same user account to
authorize on a new machine\. When authenticating on a new machine,
the username, password and email address must all match with
your existing record\.
.P
\fBnpm login\fP is an alias to \fBadduser\fP and behaves exactly the same way\.
.SS Configuration
.SS registry
.P
Default: https://registry\.npmjs\.org/
.P
The base URL of the npm package registry\. If \fBscope\fP is also specified,
this registry will only be used for packages with that scope\. \fBscope\fP defaults
to the scope of the project directory you're currently in, if any\. See npm help \fBscope\fP\|\.
.SS scope
.P
Default: none
.P
If specified, the user and login credentials given will be associated
with the specified scope\. See npm help \fBscope\fP\|\. You can use both at the same time,
e\.g\.
.P
.RS 2
.nf
npm adduser \-\-registry=http://myregistry\.example\.com \-\-scope=@myco
.fi
.RE
.P
This will set a registry for the given scope and login or create a user for
that registry at the same time\.
.SS always\-auth
.P
Default: false
.P
If specified, save configuration indicating that all requests to the given
registry should include authorization information\. Useful for private
registries\. Can be used with \fB\-\-registry\fP and / or \fB\-\-scope\fP, e\.g\.
.P
.RS 2
.nf
npm adduser \-\-registry=http://private\-registry\.example\.com \-\-always\-auth
.fi
.RE
.P
This will ensure that all requests to that registry (including for tarballs)
include an authorization header\. This setting may be necessary for use with
private registries where metadata and package tarballs are stored on hosts with
different hostnames\. See \fBalways\-auth\fP in npm help \fBconfig\fP for more details on always\-auth\. Registry\-specific configuration of \fBalways\-auth\fP takes precedence over any global configuration\.
.SS auth\-type
.RS 0
.IP \(bu 2
Default: \fB\|'legacy'\fP
.IP \(bu 2
Type: \fB\|'legacy'\fP, \fB\|'sso'\fP, \fB\|'saml'\fP, \fB\|'oauth'\fP
.RE
.P
What authentication strategy to use with \fBadduser\fP/\fBlogin\fP\|\. Some npm registries
(for example, npmE) might support alternative auth strategies besides classic
username/password entry in legacy npm\.
.SS See Also
.RS 0
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help owner
.IP \(bu 2
npm help whoami
.RE

View File

@ -0,0 +1,173 @@
.TH "NPM\-AUDIT" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-audit\fR \- Run a security audit
.SS Synopsis
.P
.RS 2
.nf
npm audit [\-\-json|\-\-parseable|\-\-audit\-level=(low|moderate|high|critical)]
npm audit fix [\-\-force|\-\-package\-lock\-only|\-\-dry\-run]
common options: [\-\-production] [\-\-only=(dev|prod)]
.fi
.RE
.SS Examples
.P
Scan your project for vulnerabilities and automatically install any compatible
updates to vulnerable dependencies:
.P
.RS 2
.nf
$ npm audit fix
.fi
.RE
.P
Run \fBaudit fix\fP without modifying \fBnode_modules\fP, but still updating the
pkglock:
.P
.RS 2
.nf
$ npm audit fix \-\-package\-lock\-only
.fi
.RE
.P
Skip updating \fBdevDependencies\fP:
.P
.RS 2
.nf
$ npm audit fix \-\-only=prod
.fi
.RE
.P
Have \fBaudit fix\fP install semver\-major updates to toplevel dependencies, not just
semver\-compatible ones:
.P
.RS 2
.nf
$ npm audit fix \-\-force
.fi
.RE
.P
Do a dry run to get an idea of what \fBaudit fix\fP will do, and \fIalso\fR output
install information in JSON format:
.P
.RS 2
.nf
$ npm audit fix \-\-dry\-run \-\-json
.fi
.RE
.P
Scan your project for vulnerabilities and just show the details, without fixing
anything:
.P
.RS 2
.nf
$ npm audit
.fi
.RE
.P
Get the detailed audit report in JSON format:
.P
.RS 2
.nf
$ npm audit \-\-json
.fi
.RE
.P
Get the detailed audit report in plain text result, separated by tab characters, allowing for
future reuse in scripting or command line post processing, like for example, selecting
some of the columns printed:
.P
.RS 2
.nf
$ npm audit \-\-parseable
.fi
.RE
.P
To parse columns, you can use for example \fBawk\fP, and just print some of them:
.P
.RS 2
.nf
$ npm audit \-\-parseable | awk \-F $'\\t' '{print $1,$4}'
.fi
.RE
.P
Fail an audit only if the results include a vulnerability with a level of moderate or higher:
.P
.RS 2
.nf
$ npm audit \-\-audit\-level=moderate
.fi
.RE
.SS Description
.P
The audit command submits a description of the dependencies configured in
your project to your default registry and asks for a report of known
vulnerabilities\. The report returned includes instructions on how to act on
this information\. The command will exit with a 0 exit code if no
vulnerabilities were found\.
.P
You can also have npm automatically fix the vulnerabilities by running \fBnpm
audit fix\fP\|\. Note that some vulnerabilities cannot be fixed automatically and
will require manual intervention or review\. Also note that since \fBnpm audit fix\fP
runs a full\-fledged \fBnpm install\fP under the hood, all configs that apply to the
installer will also apply to \fBnpm install\fP \-\- so things like \fBnpm audit fix
\-\-package\-lock\-only\fP will work as expected\.
.P
By default, the audit command will exit with a non\-zero code if any vulnerability
is found\. It may be useful in CI environments to include the \fB\-\-audit\-level\fP parameter
to specify the minimum vulnerability level that will cause the command to fail\. This
option does not filter the report output, it simply changes the command's failure
threshold\.
.SS Content Submitted
.RS 0
.IP \(bu 2
npm_version
.IP \(bu 2
node_version
.IP \(bu 2
platform
.IP \(bu 2
node_env
.IP \(bu 2
A scrubbed version of your package\-lock\.json or npm\-shrinkwrap\.json
.RE
.SS Scrubbing
.P
In order to ensure that potentially sensitive information is not included in
the audit data bundle, some dependencies may have their names (and sometimes
versions) replaced with opaque non\-reversible identifiers\. It is done for
the following dependency types:
.RS 0
.IP \(bu 2
Any module referencing a scope that is configured for a non\-default
registry has its name scrubbed\. (That is, a scope you did a \fBnpm login \-\-scope=@ourscope\fP for\.)
.IP \(bu 2
All git dependencies have their names and specifiers scrubbed\.
.IP \(bu 2
All remote tarball dependencies have their names and specifiers scrubbed\.
.IP \(bu 2
All local directory and tarball dependencies have their names and specifiers scrubbed\.
.RE
.P
The non\-reversible identifiers are a sha256 of a session\-specific UUID and the
value being replaced, ensuring a consistent value within the payload that is
different between runs\.
.SS Exit Code
.P
The \fBnpm audit\fP command will exit with a 0 exit code if no vulnerabilities were found\.
.P
If vulnerabilities were found the exit code will depend on the \fBaudit\-level\fP
configuration setting\.
.SS See Also
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help package\-locks
.IP \(bu 2
npm help config
.RE

View File

@ -0,0 +1,27 @@
.TH "NPM\-BIN" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-bin\fR \- Display npm bin folder
.SS Synopsis
.P
.RS 2
.nf
npm bin [\-g|\-\-global]
.fi
.RE
.SS Description
.P
Print the folder where npm will install executables\.
.SS See Also
.RS 0
.IP \(bu 2
npm help prefix
.IP \(bu 2
npm help root
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,57 @@
.TH "NPM\-BUGS" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-bugs\fR \- Bugs for a package in a web browser maybe
.SS Synopsis
.P
.RS 2
.nf
npm bugs [<pkgname>]
aliases: issues
.fi
.RE
.SS Description
.P
This command tries to guess at the likely location of a package's
bug tracker URL, and then tries to open it using the \fB\-\-browser\fP
config param\. If no package name is provided, it will search for
a \fBpackage\.json\fP in the current folder and use the \fBname\fP property\.
.SS Configuration
.SS browser
.RS 0
.IP \(bu 2
Default: OS X: \fB"open"\fP, Windows: \fB"start"\fP, Others: \fB"xdg\-open"\fP
.IP \(bu 2
Type: String
.RE
.P
The browser that is called by the \fBnpm bugs\fP command to open websites\.
.SS registry
.RS 0
.IP \(bu 2
Default: https://registry\.npmjs\.org/
.IP \(bu 2
Type: url
.RE
.P
The base URL of the npm package registry\.
.SS See Also
.RS 0
.IP \(bu 2
npm help docs
.IP \(bu 2
npm help view
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help package\.json
.RE

View File

@ -0,0 +1,40 @@
.TH "NPM\-BUILD" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-build\fR \- Build a package
.SS Synopsis
.P
.RS 2
.nf
npm build [<package\-folder>]
.fi
.RE
.RS 0
.IP \(bu 2
\fB<package\-folder>\fP:
A folder containing a \fBpackage\.json\fP file in its root\.
.RE
.SS Description
.P
This is the plumbing command called by \fBnpm link\fP and \fBnpm install\fP\|\.
.P
It should generally be called during installation, but if you need to run it
directly, run:
.P
.RS 2
.nf
npm run\-script build
.fi
.RE
.SS See Also
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help link
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help package\.json
.RE

View File

@ -0,0 +1,16 @@
.TH "NPM\-BUNDLE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-bundle\fR \- REMOVED
.SS Description
.P
The \fBnpm bundle\fP command has been removed in 1\.0, for the simple reason
that it is no longer necessary, as the default behavior is now to
install packages into the local space\.
.P
Just use \fBnpm install\fP now to do what \fBnpm bundle\fP used to do\.
.SS See Also
.RS 0
.IP \(bu 2
npm help install
.RE

View File

@ -0,0 +1,93 @@
.TH "NPM\-CACHE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-cache\fR \- Manipulates packages cache
.SS Synopsis
.P
.RS 2
.nf
npm cache add <tarball file>
npm cache add <folder>
npm cache add <tarball url>
npm cache add <name>@<version>
npm cache clean [<path>]
aliases: npm cache clear, npm cache rm
npm cache verify
.fi
.RE
.SS Description
.P
Used to add, list, or clean the npm cache folder\.
.RS 0
.IP \(bu 2
add:
Add the specified package to the local cache\. This command is primarily
intended to be used internally by npm, but it can provide a way to
add data to the local installation cache explicitly\.
.IP \(bu 2
clean:
Delete all data out of the cache folder\.
.IP \(bu 2
verify:
Verify the contents of the cache folder, garbage collecting any unneeded data,
and verifying the integrity of the cache index and all cached data\.
.RE
.SS Details
.P
npm stores cache data in an opaque directory within the configured \fBcache\fP,
named \fB_cacache\fP\|\. This directory is a \fBcacache\fP\-based content\-addressable cache
that stores all http request data as well as other package\-related data\. This
directory is primarily accessed through \fBpacote\fP, the library responsible for
all package fetching as of npm@5\.
.P
All data that passes through the cache is fully verified for integrity on both
insertion and extraction\. Cache corruption will either trigger an error, or
signal to \fBpacote\fP that the data must be refetched, which it will do
automatically\. For this reason, it should never be necessary to clear the cache
for any reason other than reclaiming disk space, thus why \fBclean\fP now requires
\fB\-\-force\fP to run\.
.P
There is currently no method exposed through npm to inspect or directly manage
the contents of this cache\. In order to access it, \fBcacache\fP must be used
directly\.
.P
npm will not remove data by itself: the cache will grow as new packages are
installed\.
.SS A note about the cache's design
.P
The npm cache is strictly a cache: it should not be relied upon as a persistent
and reliable data store for package data\. npm makes no guarantee that a
previously\-cached piece of data will be available later, and will automatically
delete corrupted contents\. The primary guarantee that the cache makes is that,
if it does return data, that data will be exactly the data that was inserted\.
.P
To run an offline verification of existing cache contents, use \fBnpm cache
verify\fP\|\.
.SS Configuration
.SS cache
.P
Default: \fB~/\.npm\fP on Posix, or \fB%AppData%/npm\-cache\fP on Windows\.
.P
The root cache folder\.
.SS See Also
.RS 0
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help install
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help pack
.IP \(bu 2
https://npm\.im/cacache
.IP \(bu 2
https://npm\.im/pacote
.RE

View File

@ -0,0 +1,77 @@
.TH "NPM\-CI" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-ci\fR \- Install a project with a clean slate
.SS Synopsis
.P
.RS 2
.nf
npm ci
.fi
.RE
.SS Example
.P
Make sure you have a package\-lock and an up\-to\-date install:
.P
.RS 2
.nf
$ cd \./my/npm/project
$ npm install
added 154 packages in 10s
$ ls | grep package\-lock
.fi
.RE
.P
Run \fBnpm ci\fP in that project
.P
.RS 2
.nf
$ npm ci
added 154 packages in 5s
.fi
.RE
.P
Configure Travis to build using \fBnpm ci\fP instead of \fBnpm install\fP:
.P
.RS 2
.nf
# \.travis\.yml
install:
\- npm ci
# keep the npm cache around to speed up installs
cache:
directories:
\- "$HOME/\.npm"
.fi
.RE
.SS Description
.P
This command is similar to npm help \fBinstall\fP, except it's meant to be used in
automated environments such as test platforms, continuous integration, and
deployment \-\- or any situation where you want to make sure you're doing a clean
install of your dependencies\. It can be significantly faster than a regular npm
install by skipping certain user\-oriented features\. It is also more strict than
a regular install, which can help catch errors or inconsistencies caused by the
incrementally\-installed local environments of most npm users\.
.P
In short, the main differences between using \fBnpm install\fP and \fBnpm ci\fP are:
.RS 0
.IP \(bu 2
The project \fBmust\fR have an existing \fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP\|\.
.IP \(bu 2
If dependencies in the package lock do not match those in \fBpackage\.json\fP, \fBnpm ci\fP will exit with an error, instead of updating the package lock\.
.IP \(bu 2
\fBnpm ci\fP can only install entire projects at a time: individual dependencies cannot be added with this command\.
.IP \(bu 2
If a \fBnode_modules\fP is already present, it will be automatically removed before \fBnpm ci\fP begins its install\.
.IP \(bu 2
It will never write to \fBpackage\.json\fP or any of the package\-locks: installs are essentially frozen\.
.RE
.SS See Also
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help package\-locks
.RE

View File

@ -0,0 +1,42 @@
.TH "NPM\-COMPLETION" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-completion\fR \- Tab Completion for npm
.SS Synopsis
.P
.RS 2
.nf
source <(npm completion)
.fi
.RE
.SS Description
.P
Enables tab\-completion in all npm commands\.
.P
The synopsis above
loads the completions into your current shell\. Adding it to
your ~/\.bashrc or ~/\.zshrc will make the completions available
everywhere:
.P
.RS 2
.nf
npm completion >> ~/\.bashrc
npm completion >> ~/\.zshrc
.fi
.RE
.P
You may of course also pipe the output of \fBnpm completion\fP to a file
such as \fB/usr/local/etc/bash_completion\.d/npm\fP or
\fB/etc/bash_completion\.d/npm\fP if you have a system that will read
that file for you\.
.P
When \fBCOMP_CWORD\fP, \fBCOMP_LINE\fP, and \fBCOMP_POINT\fP are defined in the
environment, \fBnpm completion\fP acts in "plumbing mode", and outputs
completions based on the arguments\.
.SS See Also
.RS 0
.IP \(bu 2
npm help developers
.IP \(bu 2
npm help npm
.RE

View File

@ -0,0 +1,96 @@
.TH "NPM\-CONFIG" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-config\fR \- Manage the npm configuration files
.SS Synopsis
.P
.RS 2
.nf
npm config set <key> <value> [\-g|\-\-global]
npm config get <key>
npm config delete <key>
npm config list [\-l] [\-\-json]
npm config edit
npm get <key>
npm set <key> <value> [\-g|\-\-global]
aliases: c
.fi
.RE
.SS Description
.P
npm gets its config settings from the command line, environment
variables, \fBnpmrc\fP files, and in some cases, the \fBpackage\.json\fP file\.
.P
See npm help npmrc for more information about the npmrc files\.
.P
See npm help config for a more thorough discussion of the mechanisms
involved\.
.P
The \fBnpm config\fP command can be used to update and edit the contents
of the user and global npmrc files\.
.SS Sub\-commands
.P
Config supports the following sub\-commands:
.SS set
.P
.RS 2
.nf
npm config set key value
.fi
.RE
.P
Sets the config key to the value\.
.P
If value is omitted, then it sets it to "true"\.
.SS get
.P
.RS 2
.nf
npm config get key
.fi
.RE
.P
Echo the config value to stdout\.
.SS list
.P
.RS 2
.nf
npm config list
.fi
.RE
.P
Show all the config settings\. Use \fB\-l\fP to also show defaults\. Use \fB\-\-json\fP
to show the settings in json format\.
.SS delete
.P
.RS 2
.nf
npm config delete key
.fi
.RE
.P
Deletes the key from all configuration files\.
.SS edit
.P
.RS 2
.nf
npm config edit
.fi
.RE
.P
Opens the config file in an editor\. Use the \fB\-\-global\fP flag to edit the
global config\.
.SS See Also
.RS 0
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help npm
.RE

View File

@ -0,0 +1,70 @@
.TH "NPM\-DEDUPE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-dedupe\fR \- Reduce duplication
.SS Synopsis
.P
.RS 2
.nf
npm dedupe
npm ddp
aliases: find\-dupes, ddp
.fi
.RE
.SS Description
.P
Searches the local package tree and attempts to simplify the overall
structure by moving dependencies further up the tree, where they can
be more effectively shared by multiple dependent packages\.
.P
For example, consider this dependency graph:
.P
.RS 2
.nf
a
+\-\- b <\-\- depends on c@1\.0\.x
| `\-\- c@1\.0\.3
`\-\- d <\-\- depends on c@~1\.0\.9
`\-\- c@1\.0\.10
.fi
.RE
.P
In this case, \fBnpm dedupe\fP will transform the tree to:
.P
.RS 2
.nf
a
+\-\- b
+\-\- d
`\-\- c@1\.0\.10
.fi
.RE
.P
Because of the hierarchical nature of node's module lookup, b and d
will both get their dependency met by the single c package at the root
level of the tree\.
.P
The deduplication algorithm walks the tree, moving each dependency as far
up in the tree as possible, even if duplicates are not found\. This will
result in both a flat and deduplicated tree\.
.P
If a suitable version exists at the target location in the tree
already, then it will be left untouched, but the other duplicates will
be deleted\.
.P
Arguments are ignored\. Dedupe always acts on the entire tree\.
.P
Modules
.P
Note that this operation transforms the dependency tree, but will never
result in new modules being installed\.
.SS See Also
.RS 0
.IP \(bu 2
npm help ls
.IP \(bu 2
npm help update
.IP \(bu 2
npm help install
.RE

View File

@ -0,0 +1,38 @@
.TH "NPM\-DEPRECATE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-deprecate\fR \- Deprecate a version of a package
.SS Synopsis
.P
.RS 2
.nf
npm deprecate <pkg>[@<version>] <message>
.fi
.RE
.SS Description
.P
This command will update the npm registry entry for a package, providing
a deprecation warning to all who attempt to install it\.
.P
It works on version ranges \fIhttps://semver\.npmjs\.com/\fR as well as specific
versions, so you can do something like this:
.P
.RS 2
.nf
npm deprecate my\-thing@"< 0\.2\.3" "critical bug fixed in v0\.2\.3"
.fi
.RE
.P
Note that you must be the package owner to deprecate something\. See the
\fBowner\fP and \fBadduser\fP help topics\.
.P
To un\-deprecate a package, specify an empty string (\fB""\fP) for the \fBmessage\fP
argument\. Note that you must use double quotes with no space between them to
format an empty string\.
.SS See Also
.RS 0
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help registry
.RE

View File

@ -0,0 +1,112 @@
.HR
.P
section: cli\-commands
title: npm\-dist\-tag
description: Modify package distribution tags
.HR
.TH "NPM\-DIST\-TAG" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-dist-tag\fR \- Modify package distribution tags
.SS Synopsis
.P
.RS 2
.nf
npm dist\-tag add <pkg>@<version> [<tag>]
npm dist\-tag rm <pkg> <tag>
npm dist\-tag ls [<pkg>]
aliases: dist\-tags
.fi
.RE
.SS Description
.P
Add, remove, and enumerate distribution tags on a package:
.RS 0
.IP \(bu 2
add:
Tags the specified version of the package with the specified tag, or the
\fB\-\-tag\fP config if not specified\. If you have two\-factor authentication on
auth\-and\-writes then youll need to include a one\-time password on the
command line with \fB\-\-otp <one\-time password>\fP\|\.
.IP \(bu 2
rm:
Clear a tag that is no longer in use from the package\.
.IP \(bu 2
ls:
Show all of the dist\-tags for a package, defaulting to the package in
the current prefix\. This is the default action if none is specified\.
.RE
.P
A tag can be used when installing packages as a reference to a version instead
of using a specific version number:
.P
.RS 2
.nf
npm install <name>@<tag>
.fi
.RE
.P
When installing dependencies, a preferred tagged version may be specified:
.P
.RS 2
.nf
npm install \-\-tag <tag>
.fi
.RE
.P
This also applies to \fBnpm dedupe\fP\|\.
.P
Publishing a package sets the \fBlatest\fP tag to the published version unless the
\fB\-\-tag\fP option is used\. For example, \fBnpm publish \-\-tag=beta\fP\|\.
.P
By default, \fBnpm install <pkg>\fP (without any \fB@<version>\fP or \fB@<tag>\fP
specifier) installs the \fBlatest\fP tag\.
.SS Purpose
.P
Tags can be used to provide an alias instead of version numbers\.
.P
For example, a project might choose to have multiple streams of development
and use a different tag for each stream,
e\.g\., \fBstable\fP, \fBbeta\fP, \fBdev\fP, \fBcanary\fP\|\.
.P
By default, the \fBlatest\fP tag is used by npm to identify the current version of
a package, and \fBnpm install <pkg>\fP (without any \fB@<version>\fP or \fB@<tag>\fP
specifier) installs the \fBlatest\fP tag\. Typically, projects only use the \fBlatest\fP
tag for stable release versions, and use other tags for unstable versions such
as prereleases\.
.P
The \fBnext\fP tag is used by some projects to identify the upcoming version\.
.P
By default, other than \fBlatest\fP, no tag has any special significance to npm
itself\.
.SS Caveats
.P
This command used to be known as \fBnpm tag\fP, which only created new tags, and so
had a different syntax\.
.P
Tags must share a namespace with version numbers, because they are specified in
the same slot: \fBnpm install <pkg>@<version>\fP vs \fBnpm install <pkg>@<tag>\fP\|\.
.P
Tags that can be interpreted as valid semver ranges will be rejected\. For
example, \fBv1\.4\fP cannot be used as a tag, because it is interpreted by semver as
\fB>=1\.4\.0 <1\.5\.0\fP\|\. See https://github\.com/npm/npm/issues/6082\|\.
.P
The simplest way to avoid semver problems with tags is to use tags that do not
begin with a number or the letter \fBv\fP\|\.
.SS See Also
.RS 0
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help install
.IP \(bu 2
npm help dedupe
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,57 @@
.TH "NPM\-DOCS" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-docs\fR \- Docs for a package in a web browser maybe
.SS Synopsis
.P
.RS 2
.nf
npm docs [<pkgname> [<pkgname> \.\.\.]]
npm docs \.
npm home [<pkgname> [<pkgname> \.\.\.]]
npm home \.
.fi
.RE
.SS Description
.P
This command tries to guess at the likely location of a package's
documentation URL, and then tries to open it using the \fB\-\-browser\fP
config param\. You can pass multiple package names at once\. If no
package name is provided, it will search for a \fBpackage\.json\fP in
the current folder and use the \fBname\fP property\.
.SS Configuration
.SS browser
.RS 0
.IP \(bu 2
Default: OS X: \fB"open"\fP, Windows: \fB"start"\fP, Others: \fB"xdg\-open"\fP
.IP \(bu 2
Type: String
.RE
.P
The browser that is called by the \fBnpm docs\fP command to open websites\.
.SS registry
.RS 0
.IP \(bu 2
Default: https://registry\.npmjs\.org/
.IP \(bu 2
Type: url
.RE
.P
The base URL of the npm package registry\.
.SS See Also
.RS 0
.IP \(bu 2
npm help view
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help package\.json
.RE

View File

@ -0,0 +1,113 @@
.TH "NPM\-DOCTOR" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-doctor\fR \- Check your environments
.SS Synopsis
.P
.RS 2
.nf
npm doctor
.fi
.RE
.SS Description
.P
\fBnpm doctor\fP runs a set of checks to ensure that your npm installation has
what it needs to manage your JavaScript packages\. npm is mostly a standalone tool, but it does
have some basic requirements that must be met:
.RS 0
.IP \(bu 2
Node\.js and git must be executable by npm\.
.IP \(bu 2
The primary npm registry, \fBregistry\.npmjs\.com\fP, or another service that uses
the registry API, is available\.
.IP \(bu 2
The directories that npm uses, \fBnode_modules\fP (both locally and globally),
exist and can be written by the current user\.
.IP \(bu 2
The npm cache exists, and the package tarballs within it aren't corrupt\.
.RE
.P
Without all of these working properly, npm may not work properly\. Many issues
are often attributable to things that are outside npm's code base, so \fBnpm
doctor\fP confirms that the npm installation is in a good state\.
.P
Also, in addition to this, there are also very many issue reports due to using
old versions of npm\. Since npm is constantly improving, running \fBnpm@latest\fP is
better than an old version\.
.P
\fBnpm doctor\fP verifies the following items in your environment, and if there are
any recommended changes, it will display them\.
.SS \fBnpm ping\fP
.P
By default, npm installs from the primary npm registry, \fBregistry\.npmjs\.org\fP\|\.
\fBnpm doctor\fP hits a special ping endpoint within the registry\. This can also be
checked with \fBnpm ping\fP\|\. If this check fails, you may be using a proxy that
needs to be configured, or may need to talk to your IT staff to get access over
HTTPS to \fBregistry\.npmjs\.org\fP\|\.
.P
This check is done against whichever registry you've configured (you can see
what that is by running \fBnpm config get registry\fP), and if you're using a
private registry that doesn't support the \fB/whoami\fP endpoint supported by the
primary registry, this check may fail\.
.SS \fBnpm \-v\fP
.P
While Node\.js may come bundled with a particular version of npm, it's the
policy of the CLI team that we recommend all users run \fBnpm@latest\fP if they
can\. As the CLI is maintained by a small team of contributors, there are only
resources for a single line of development, so npm's own long\-term support
releases typically only receive critical security and regression fixes\. The
team believes that the latest tested version of npm is almost always likely to
be the most functional and defect\-free version of npm\.
.SS \fBnode \-v\fP
.P
For most users, in most circumstances, the best version of Node will be the
latest long\-term support (LTS) release\. Those of you who want access to new
ECMAscript features or bleeding\-edge changes to Node's standard library may be
running a newer version, and some of you may be required to run an older
version of Node because of enterprise change control policies\. That's OK! But
in general, the npm team recommends that most users run Node\.js LTS\.
.SS \fBnpm config get registry\fP
.P
Some of you may be installing from private package registries for your project
or company\. That's great! Others of you may be following tutorials or
StackOverflow questions in an effort to troubleshoot problems you may be
having\. Sometimes, this may entail changing the registry you're pointing at\.
This part of \fBnpm doctor\fP just lets you, and maybe whoever's helping you with
support, know that you're not using the default registry\.
.SS \fBwhich git\fP
.P
While it's documented in the README, it may not be obvious that npm needs Git
installed to do many of the things that it does\. Also, in some cases
especially on Windows you may have Git set up in such a way that it's not
accessible via your \fBPATH\fP so that npm can find it\. This check ensures that Git
is available\.
.SS Permissions checks
.RS 0
.IP \(bu 2
Your cache must be readable and writable by the user running npm\.
.IP \(bu 2
Global package binaries must be writable by the user running npm\.
.IP \(bu 2
Your local \fBnode_modules\fP path, if you're running \fBnpm doctor\fP with a project
directory, must be readable and writable by the user running npm\.
.RE
.SS Validate the checksums of cached packages
.P
When an npm package is published, the publishing process generates a checksum
that npm uses at install time to verify that the package didn't get corrupted
in transit\. \fBnpm doctor\fP uses these checksums to validate the package tarballs
in your local cache (you can see where that cache is located with \fBnpm config
get cache\fP, and see what's in that cache with \fBnpm cache ls\fP probably more
than you were expecting!)\. In the event that there are corrupt packages in your
cache, you should probably run \fBnpm cache clean\fP and reset the cache\.
.SS See Also
.RS 0
.IP \(bu 2
npm help bugs
.IP \(bu 2
npm help help
.IP \(bu 2
npm help ping
.RE

View File

@ -0,0 +1,49 @@
.TH "NPM\-EDIT" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-edit\fR \- Edit an installed package
.SS Synopsis
.P
.RS 2
.nf
npm edit <pkg>[/<subpkg>\.\.\.]
.fi
.RE
.SS Description
.P
Selects a (sub)dependency in the current
working directory and opens the package folder in the default editor
(or whatever you've configured as the npm \fBeditor\fP config \-\- see
\fBnpm\-config\fP \fInpm\-config)\.\fR
.P
After it has been edited, the package is rebuilt so as to pick up any
changes in compiled packages\.
.P
For instance, you can do \fBnpm install connect\fP to install connect
into your package, and then \fBnpm edit connect\fP to make a few
changes to your locally installed copy\.
.SS Configuration
.SS editor
.RS 0
.IP \(bu 2
Default: \fBEDITOR\fP environment variable if set, or \fB"vi"\fP on Posix,
or \fB"notepad"\fP on Windows\.
.IP \(bu 2
Type: path
.RE
.P
The command to run for \fBnpm edit\fP or \fBnpm config edit\fP\|\.
.SS See Also
.RS 0
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help explore
.IP \(bu 2
npm help install
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,60 @@
.HR
.P
section: cli\-commands
title: npm\-explore
description: Browse an installed package
.HR
.TH "NPM\-EXPLORE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-explore\fR \- Browse an installed package
.SS Synopsis
.P
.RS 2
.nf
npm explore <pkg> [ \-\- <command>]
.fi
.RE
.SS Description
.P
Spawn a subshell in the directory of the installed package specified\.
.P
If a command is specified, then it is run in the subshell, which then
immediately terminates\.
.P
This is particularly handy in the case of git submodules in the
\fBnode_modules\fP folder:
.P
.RS 2
.nf
npm explore some\-dependency \-\- git pull origin master
.fi
.RE
.P
Note that the package is \fInot\fR automatically rebuilt afterwards, so be
sure to use \fBnpm rebuild <pkg>\fP if you make any changes\.
.SS Configuration
.SS shell
.RS 0
.IP \(bu 2
Default: SHELL environment variable, or "bash" on Posix, or "cmd" on
Windows
.IP \(bu 2
Type: path
.RE
.P
The shell to run for the \fBnpm explore\fP command\.
.SS See Also
.RS 0
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help edit
.IP \(bu 2
npm help rebuild
.IP \(bu 2
npm help build
.IP \(bu 2
npm help install
.RE

View File

@ -0,0 +1,77 @@
.TH "NPM\-FUND" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-fund\fR \- Retrieve funding information
.SS Synopsis
.P
.RS 2
.nf
npm fund [<pkg>]
.fi
.RE
.SS Description
.P
This command retrieves information on how to fund the dependencies of
a given project\. If no package name is provided, it will list all
dependencies that are looking for funding in a tree\-structure in which
are listed the type of funding and the url to visit\. If a package name
is provided then it tries to open its funding url using the \fB\-\-browser\fP
config param; if there are multiple funding sources for the package, the
user will be instructed to pass the \fB\-\-which\fP command to disambiguate\.
.P
The list will avoid duplicated entries and will stack all packages
that share the same type/url as a single entry\. Given this nature the
list is not going to have the same shape of the output from \fBnpm ls\fP\|\.
.SS Configuration
.SS browser
.RS 0
.IP \(bu 2
Default: OS X: \fB"open"\fP, Windows: \fB"start"\fP, Others: \fB"xdg\-open"\fP
.IP \(bu 2
Type: String
.RE
.P
The browser that is called by the \fBnpm fund\fP command to open websites\.
.SS json
.RS 0
.IP \(bu 2
Type: Boolean
.IP \(bu 2
Default: false
.RE
.P
Show information in JSON format\.
.SS unicode
.RS 0
.IP \(bu 2
Type: Boolean
.IP \(bu 2
Default: true
.RE
.P
Whether to represent the tree structure using unicode characters\.
Set it to \fBfalse\fP in order to use all\-ansi output\.
.SS which
.RS 0
.IP \(bu 2
Type: Number
.IP \(bu 2
Default: undefined
.RE
.P
If there are multiple funding sources, which 1\-indexed source URL to open\.
.SH See Also
.RS 0
.IP \(bu 2
npm help docs
.IP \(bu 2
npm help config
.IP \(bu 2
npm help install
.IP \(bu 2
npm help ls
.RE

View File

@ -0,0 +1,42 @@
.TH "NPM\-HELP\-SEARCH" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-help-search\fR \- Search npm help documentation
.SS Synopsis
.P
.RS 2
.nf
npm help\-search <text>
.fi
.RE
.SS Description
.P
This command will search the npm markdown documentation files for the
terms provided, and then list the results, sorted by relevance\.
.P
If only one result is found, then it will show that help topic\.
.P
If the argument to \fBnpm help\fP is not a known help topic, then it will
call \fBhelp\-search\fP\|\. It is rarely if ever necessary to call this
command directly\.
.SS Configuration
.SS long
.RS 0
.IP \(bu 2
Type: Boolean
.IP \(bu 2
Default: false
.RE
.P
If true, the "long" flag will cause help\-search to output context around
where the terms were found in the documentation\.
.P
If false, then help\-search will just list out the help topics found\.
.SS See Also
.RS 0
.IP \(bu 2
npm help npm
.IP \(bu 2
npm help help
.RE

View File

@ -0,0 +1,47 @@
.TH "NPM\-HELP" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-help\fR \- Get help on npm
.SS Synopsis
.P
.RS 2
.nf
npm help <term> [<terms\.\.>]
.fi
.RE
.SS Description
.P
If supplied a topic, then show the appropriate documentation page\.
.P
If the topic does not exist, or if multiple terms are provided, then run
the \fBhelp\-search\fP command to find a match\. Note that, if \fBhelp\-search\fP
finds a single subject, then it will run \fBhelp\fP on that topic, so unique
matches are equivalent to specifying a topic name\.
.SS Configuration
.SS viewer
.RS 0
.IP \(bu 2
Default: "man" on Posix, "browser" on Windows
.IP \(bu 2
Type: path
.RE
.P
The program to use to view help content\.
.P
Set to \fB"browser"\fP to view html help content in the default web browser\.
.SS See Also
.RS 0
.IP \(bu 2
npm help npm
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help help\-search
.RE

View File

@ -0,0 +1,96 @@
.TH "NPM\-HOOK" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-hook\fR \- Manage registry hooks
.SS Synopsis
.P
.RS 2
.nf
npm hook ls [pkg]
npm hook add <entity> <url> <secret>
npm hook update <id> <url> [secret]
npm hook rm <id>
.fi
.RE
.SS Example
.P
Add a hook to watch a package for changes:
.P
.RS 2
.nf
$ npm hook add lodash https://example\.com/ my\-shared\-secret
.fi
.RE
.P
Add a hook to watch packages belonging to the user \fBsubstack\fP:
.P
.RS 2
.nf
$ npm hook add ~substack https://example\.com/ my\-shared\-secret
.fi
.RE
.P
Add a hook to watch packages in the scope \fB@npm\fP
.P
.RS 2
.nf
$ npm hook add @npm https://example\.com/ my\-shared\-secret
.fi
.RE
.P
List all your active hooks:
.P
.RS 2
.nf
$ npm hook ls
.fi
.RE
.P
List your active hooks for the \fBlodash\fP package:
.P
.RS 2
.nf
$ npm hook ls lodash
.fi
.RE
.P
Update an existing hook's url:
.P
.RS 2
.nf
$ npm hook update id\-deadbeef https://my\-new\-website\.here/
.fi
.RE
.P
Remove a hook:
.P
.RS 2
.nf
$ npm hook rm id\-deadbeef
.fi
.RE
.SS Description
.P
Allows you to manage npm hooks \fIhttps://blog\.npmjs\.org/post/145260155635/introducing\-hooks\-get\-notifications\-of\-npm\fR,
including adding, removing, listing, and updating\.
.P
Hooks allow you to configure URL endpoints that will be notified whenever a
change happens to any of the supported entity types\. Three different types of
entities can be watched by hooks: packages, owners, and scopes\.
.P
To create a package hook, simply reference the package name\.
.P
To create an owner hook, prefix the owner name with \fB~\fP (as in, \fB~youruser\fP)\.
.P
To create a scope hook, prefix the scope name with \fB@\fP (as in, \fB@yourscope\fP)\.
.P
The hook \fBid\fP used by \fBupdate\fP and \fBrm\fP are the IDs listed in \fBnpm hook ls\fP for
that particular hook\.
.P
The shared secret will be sent along to the URL endpoint so you can verify the
request came from your own configured hook\.
.SS See Also
.RS 0
.IP \(bu 2
"Introducing Hooks" blog post \fIhttps://blog\.npmjs\.org/post/145260155635/introducing\-hooks\-get\-notifications\-of\-npm\fR
.RE

View File

@ -0,0 +1,90 @@
.TH "NPM\-INIT" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-init\fR \- create a package\.json file
.SS Synopsis
.P
.RS 2
.nf
npm init [\-\-force|\-f|\-\-yes|\-y|\-\-scope]
npm init <@scope> (same as `npx <@scope>/create`)
npm init [<@scope>/]<name> (same as `npx [<@scope>/]create\-<name>`)
.fi
.RE
.SS Examples
.P
Create a new React\-based project using \fBcreate\-react\-app\fP \fIhttps://npm\.im/create\-react\-app\fR:
.P
.RS 2
.nf
$ npm init react\-app \./my\-react\-app
.fi
.RE
.P
Create a new \fBesm\fP\-compatible package using \fBcreate\-esm\fP \fIhttps://npm\.im/create\-esm\fR:
.P
.RS 2
.nf
$ mkdir my\-esm\-lib && cd my\-esm\-lib
$ npm init esm \-\-yes
.fi
.RE
.P
Generate a plain old package\.json using legacy init:
.P
.RS 2
.nf
$ mkdir my\-npm\-pkg && cd my\-npm\-pkg
$ git init
$ npm init
.fi
.RE
.P
Generate it without having it ask any questions:
.P
.RS 2
.nf
$ npm init \-y
.fi
.RE
.SS Description
.P
\fBnpm init <initializer>\fP can be used to set up a new or existing npm package\.
.P
\fBinitializer\fP in this case is an npm package named \fBcreate\-<initializer>\fP, which
will be installed by \fBnpx\fP \fIhttps://npm\.im/npx\fR, and then have its main bin
executed \-\- presumably creating or updating \fBpackage\.json\fP and running any other
initialization\-related operations\.
.P
The init command is transformed to a corresponding \fBnpx\fP operation as follows:
.RS 0
.IP \(bu 2
\fBnpm init foo\fP \-> \fBnpx create\-foo\fP
.IP \(bu 2
\fBnpm init @usr/foo\fP \-> \fBnpx @usr/create\-foo\fP
.IP \(bu 2
\fBnpm init @usr\fP \-> \fBnpx @usr/create\fP
.RE
.P
Any additional options will be passed directly to the command, so \fBnpm init foo
\-\-hello\fP will map to \fBnpx create\-foo \-\-hello\fP\|\.
.P
If the initializer is omitted (by just calling \fBnpm init\fP), init will fall back
to legacy init behavior\. It will ask you a bunch of questions, and then write a
package\.json for you\. It will attempt to make reasonable guesses based on
existing fields, dependencies, and options selected\. It is strictly additive, so
it will keep any fields and values that were already set\. You can also use
\fB\-y\fP/\fB\-\-yes\fP to skip the questionnaire altogether\. If you pass \fB\-\-scope\fP, it
will create a scoped package\.
.SS See Also
.RS 0
.IP \(bu 2
https://github\.com/isaacs/init\-package\-json
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help version
.IP \(bu 2
npm help scope
.RE

View File

@ -0,0 +1,23 @@
.TH "NPM" "" "August 2021" "" ""
.SH "NAME"
\fBnpm\fR
.SS Synopsis
.P
.RS 2
.nf
npm install\-ci\-test
alias: npm cit
.fi
.RE
.SS Description
.P
This command runs an \fBnpm ci\fP followed immediately by an \fBnpm test\fP\|\.
.SS See Also
.RS 0
.IP \(bu 2
npm help ci
.IP \(bu 2
npm help test
.RE

View File

@ -0,0 +1,32 @@
.TH "NPM" "" "August 2021" "" ""
.SH "NAME"
\fBnpm\fR
.SS Synopsis
.P
.RS 2
.nf
npm install\-test (with no args, in package dir)
npm install\-test [<@scope>/]<name>
npm install\-test [<@scope>/]<name>@<tag>
npm install\-test [<@scope>/]<name>@<version>
npm install\-test [<@scope>/]<name>@<version range>
npm install\-test <tarball file>
npm install\-test <tarball url>
npm install\-test <folder>
alias: npm it
common options: [\-\-save|\-\-save\-dev|\-\-save\-optional] [\-\-save\-exact] [\-\-dry\-run]
.fi
.RE
.SS Description
.P
This command runs an \fBnpm install\fP followed immediately by an \fBnpm test\fP\|\. It
takes exactly the same arguments as \fBnpm install\fP\|\.
.SS See Also
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help test
.RE

View File

@ -0,0 +1,565 @@
.TH "NPM\-INSTALL" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-install\fR \- Install a package
.SS Synopsis
.P
.RS 2
.nf
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>
npm install <alias>@npm:<name>
npm install <git\-host>:<git\-user>/<repo\-name>
npm install <git repo url>
npm install <tarball file>
npm install <tarball url>
npm install <folder>
aliases: npm i, npm add
common options: [\-P|\-\-save\-prod|\-D|\-\-save\-dev|\-O|\-\-save\-optional] [\-E|\-\-save\-exact] [\-B|\-\-save\-bundle] [\-\-no\-save] [\-\-dry\-run]
.fi
.RE
.SS Description
.P
This command installs a package, and any packages that it depends on\. If the
package has a package\-lock or shrinkwrap file, the installation of dependencies
will be driven by that, with an \fBnpm\-shrinkwrap\.json\fP taking precedence if both
files exist\. See npm help package\-lock\.json and npm help \fBshrinkwrap\fP\|\.
.P
A \fBpackage\fP is:
.RS 0
.IP \(bu 2
a) a folder containing a program described by a npm help \fBpackage\.json\fP file
.IP \(bu 2
b) a gzipped tarball containing (a)
.IP \(bu 2
c) a url that resolves to (b)
.IP \(bu 2
d) a \fB<name>@<version>\fP that is published on the registry (see npm help \fBregistry\fP) with (c)
.IP \(bu 2
e) a \fB<name>@<tag>\fP (see npm help \fBdist\-tag\fP) that points to (d)
.IP \(bu 2
f) a \fB<name>\fP that has a "latest" tag satisfying (e)
.IP \(bu 2
g) a \fB<git remote url>\fP that resolves to (a)
.RE
.P
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)\.
.RS 0
.IP \(bu 2
\fBnpm install\fP (in package directory, no arguments):
Install the dependencies in the local node_modules folder\.
In global mode (ie, with \fB\-g\fP or \fB\-\-global\fP appended to the command),
it installs the current package context (ie, the current working
directory) as a global package\.
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\|\.
.QP
NOTE: The \fB\-\-production\fP flag has no particular meaning when adding a
dependency to a project\.
.
.IP \(bu 2
\fBnpm install <folder>\fP:
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
toplevel \fBnode_modules\fP as they would for other types of dependencies\.
.IP \(bu 2
\fBnpm install <tarball file>\fP:
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 \fBnpm link\fP\|\.
Tarball requirements:
.RS
.IP \(bu 2
The filename \fImust\fR use \fB\|\.tar\fP, \fB\|\.tar\.gz\fP, or \fB\|\.tgz\fP as
the extension\.
.IP \(bu 2
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)\.
.IP \(bu 2
The package must contain a \fBpackage\.json\fP file with \fBname\fP and \fBversion\fP properties\.
Example:
.P
.RS 2
.nf
npm install \./package\.tgz
.fi
.RE
.RE
.IP \(bu 2
\fBnpm install <tarball url>\fP:
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
.nf
npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
.fi
.RE
.IP \(bu 2
\fBnpm install [<@scope>/]<name>\fP:
Do a \fB<name>@<tag>\fP install, where \fB<tag>\fP is the "tag" config\. (See
npm help \fBconfig\fP\|\. The config's default value is \fBlatest\fP\|\.)
In most cases, this will install the version of the modules tagged as
\fBlatest\fP on the npm registry\.
Example:
.P
.RS 2
.nf
npm install sax
.fi
.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
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
.fi
.RE
.RE
.P
.RS 2
.nf
`npm install` saves any specified packages into `dependencies` by default\.
Additionally, you can control where and how they get saved with some
additional flags:
* `\-P, \-\-save\-prod`: Package will appear in your `dependencies`\. This is the
default unless `\-D` or `\-O` are present\.
* `\-D, \-\-save\-dev`: Package will appear in your `devDependencies`\.
* `\-O, \-\-save\-optional`: Package will appear in your `optionalDependencies`\.
* `\-\-no\-save`: Prevents saving to `dependencies`\.
When using any of the above options to save dependencies to your
package\.json, there are two additional, optional flags:
* `\-E, \-\-save\-exact`: Saved dependencies will be configured with an
exact version rather than using npm's default semver range
operator\.
* `\-B, \-\-save\-bundle`: Saved dependencies will also be added to your `bundleDependencies` list\.
Further, if you have an `npm\-shrinkwrap\.json` or `package\-lock\.json` then it
will be updated as well\.
`<scope>` is optional\. The package will be downloaded from the registry
associated with the specified scope\. If no registry is associated with
the given scope the default registry is assumed\. See npm help `scope`\.
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\.
Examples:
```bash
npm install sax
npm install githubname/reponame
npm install @myorg/privatepackage
npm install node\-tap \-\-save\-dev
npm install dtrace\-provider \-\-save\-optional
npm install readable\-stream \-\-save\-exact
npm install ansi\-regex \-\-save\-bundle
```
**Note**: If there is a file or folder named `<name>` in the current
working directory, then it will try to install that, and only try to
fetch the package by name if it is not valid\.
.fi
.RE
.RS 0
.IP \(bu 2
\fBnpm install [<@scope>/]<name>@<tag>\fP:
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
.nf
npm install sax@latest
npm install @myorg/mypackage@latest
.fi
.RE
.IP \(bu 2
\fBnpm install [<@scope>/]<name>@<version>\fP:
Install the specified version of the package\. This will fail if the
version has not been published to the registry\.
Example:
.P
.RS 2
.nf
npm install sax@0\.1\.1
npm install @myorg/privatepackage@1\.5\.0
.fi
.RE
.IP \(bu 2
\fBnpm install [<@scope>/]<name>@<version range>\fP:
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\.
Example:
.P
.RS 2
.nf
npm install sax@">=0\.1\.0 <0\.2\.0"
npm install @myorg/privatepackage@">=0\.1\.0 <0\.2\.0"
.fi
.RE
.IP \(bu 2
\fBnpm install <git remote url>\fP:
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\.
.P
.RS 2
.nf
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit\-ish> | #semver:<semver>]
.fi
.RE
\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
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\.
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\.
The following git environment variables are recognized by npm and will be
added to the environment when running git:
.RS
.IP \(bu 2
\fBGIT_ASKPASS\fP
.IP \(bu 2
\fBGIT_EXEC_PATH\fP
.IP \(bu 2
\fBGIT_PROXY_COMMAND\fP
.IP \(bu 2
\fBGIT_SSH\fP
.IP \(bu 2
\fBGIT_SSH_COMMAND\fP
.IP \(bu 2
\fBGIT_SSL_CAINFO\fP
.IP \(bu 2
\fBGIT_SSL_NO_VERIFY\fP
See the git man page for details\.
Examples:
.P
.RS 2
.nf
npm install git+ssh://git@github\.com:npm/cli\.git#v1\.0\.27
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
.fi
.RE
.RE
.IP \(bu 2
\fBnpm install <githubname>/<githubrepo>[#<commit\-ish>]\fP:
.IP \(bu 2
\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\|\.
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
be installed if the package has a \fBprepare\fP script, before the package is
done installing\.
Examples:
.P
.RS 2
.nf
npm install mygithubuser/myproject
npm install github:mygithubuser/myproject
.fi
.RE
.IP \(bu 2
\fBnpm install gist:[<githubname>/]<gistID>[#<commit\-ish>|#semver:<semver>]\fP:
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
optional and will not be saved in \fBpackage\.json\fP\|\.
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\.
Example:
.P
.RS 2
.nf
npm install gist:101a11beef
.fi
.RE
.IP \(bu 2
\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\|\.
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
be installed if the package has a \fBprepare\fP script, before the package is
done installing\.
Example:
.P
.RS 2
.nf
npm install bitbucket:mybitbucketuser/myproject
.fi
.RE
.IP \(bu 2
\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\|\.
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
be installed if the package has a \fBprepare\fP script, before the package is
done installing\.
Example:
.P
.RS 2
.nf
npm install gitlab:mygitlabuser/myproject
npm install gitlab:myusr/myproj#semver:^5\.0
.fi
.RE
.RE
.P
You may combine multiple arguments, and even multiple types of arguments\.
For example:
.P
.RS 2
.nf
npm install sax@">=0\.1\.0 <0\.2\.0" bench supervisor
.fi
.RE
.P
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\.
.P
The \fB\-\-dry\-run\fP argument will report in the usual way what the install would
have done without actually installing anything\.
.P
The \fB\-\-package\-lock\-only\fP argument will only update the \fBpackage\-lock\.json\fP,
instead of checking \fBnode_modules\fP and downloading dependencies\.
.P
The \fB\-f\fP or \fB\-\-force\fP argument will force npm to fetch remote resources even if a
local copy exists on disk\.
.P
.RS 2
.nf
npm install sax \-\-force
.fi
.RE
.P
The \fB\-\-no\-fund\fP argument will hide the message displayed at the end of each
install that acknowledges the number of dependencies looking for funding\.
See \fBnpm\-fund(1)\fP
.P
The \fB\-g\fP or \fB\-\-global\fP argument will cause npm to install the package globally
rather than locally\. See npm help folders\.
.P
The \fB\-\-global\-style\fP argument will cause npm to 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\.
.P
The \fB\-\-ignore\-scripts\fP argument will cause npm to not execute any
scripts defined in the package\.json\. See npm help \fBscripts\fP\|\.
.P
The \fB\-\-legacy\-bundling\fP argument will cause npm to install the package such
that versions of npm prior to 1\.4, such as the one included with node 0\.8,
can install the package\. This eliminates all automatic deduping\.
.P
The \fB\-\-link\fP argument will cause npm to link global installs into the
local space in some cases\.
.P
The \fB\-\-no\-bin\-links\fP argument will prevent npm from creating symlinks for
any binaries the package might contain\.
.P
The \fB\-\-no\-optional\fP argument will prevent optional dependencies from
being installed\.
.P
The \fB\-\-no\-shrinkwrap\fP argument, which will ignore an available
package lock or shrinkwrap file and use the package\.json instead\.
.P
The \fB\-\-no\-package\-lock\fP argument will prevent npm from creating a
\fBpackage\-lock\.json\fP file\. When running with package\-lock's disabled npm
will not automatically prune your node modules when installing\.
.P
The \fB\-\-nodedir=/path/to/node/source\fP argument will allow npm to find the
node source code so that npm can compile native modules\.
.P
The \fB\-\-only={prod[uction]|dev[elopment]}\fP argument will cause either only
\fBdevDependencies\fP or only non\-\fBdevDependencies\fP to be installed regardless of the \fBNODE_ENV\fP\|\.
.P
The \fB\-\-no\-audit\fP argument can be used to disable sending of audit reports to
the configured registries\. See \fBnpm\-audit\fP \fInpm\-audit\fR for details on what is sent\.
.P
See npm help \fBconfig\fP\|\. Many of the configuration params have some
effect on installation, since that's most of what npm does\.
.SS Algorithm
.P
To install a package, npm uses the following algorithm:
.P
.RS 2
.nf
load the existing node_modules tree from disk
clone the tree
fetch the package\.json and assorted metadata and add it to the clone
walk the clone and add any missing dependencies
dependencies will be added as close to the top as is possible
without breaking any other modules
compare the original tree with the cloned tree and make a list of
actions to take to convert one to the other
execute all of the actions, deepest first
kinds of actions are install, update, remove and move
.fi
.RE
.P
For this \fBpackage{dep}\fP structure: \fBA{B,C}, B{C}, C{D}\fP,
this algorithm produces:
.P
.RS 2
.nf
A
+\-\- B
+\-\- C
+\-\- D
.fi
.RE
.P
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\.
.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
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\.
.P
See npm help folders for a more detailed description of the specific folder structures that npm creates\.
.SS Limitations of npm's Install Algorithm
.P
npm will refuse to install any package with an identical name to the
current package\. This can be overridden with the \fB\-\-force\fP flag, but in
most cases can simply be addressed by changing the local package name\.
.P
There are some very rare and pathological edge\-cases where a cycle can
cause npm to try to install a never\-ending tree of packages\. Here is
the simplest case:
.P
.RS 2
.nf
A \-> B \-> A' \-> B' \-> A \-> B \-> A' \-> B' \-> A \-> \.\.\.
.fi
.RE
.P
where \fBA\fP is some version of a package, and \fBA'\fP is a different version
of the same package\. Because \fBB\fP depends on a different version of \fBA\fP
than the one that is already in the tree, it must install a separate
copy\. The same is true of \fBA'\fP, which must install \fBB'\fP\|\. Because \fBB'\fP
depends on the original version of \fBA\fP, which has been overridden, the
cycle falls into infinite regress\.
.P
To avoid this situation, npm flat\-out refuses to install any
\fBname@version\fP that is already present anywhere in the tree of package
folder ancestors\. A more correct, but more complex, solution would be
to symlink the existing version into the new location\. If this ever
affects a real use\-case, it will be investigated\.
.SS See Also
.RS 0
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help update
.IP \(bu 2
npm help audit
.IP \(bu 2
npm help fund
.IP \(bu 2
npm help link
.IP \(bu 2
npm help rebuild
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help build
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help dist\-tag
.IP \(bu 2
npm help uninstall
.IP \(bu 2
npm help shrinkwrap
.IP \(bu 2
npm help package\.json
.RE

View File

@ -0,0 +1,101 @@
.TH "NPM\-LINK" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-link\fR \- Symlink a package folder
.SS Synopsis
.P
.RS 2
.nf
npm link (in package dir)
npm link [<@scope>/]<pkg>[@<version>]
alias: npm ln
.fi
.RE
.SS Description
.P
Package linking is a two\-step process\.
.P
First, \fBnpm link\fP in a package folder will create a symlink in the global folder
\fB{prefix}/lib/node_modules/<package>\fP that links to the package where the \fBnpm
link\fP command was executed\. It will also link any bins in the package to \fB{prefix}/bin/{name}\fP\|\.
Note that \fBnpm link\fP uses the global prefix (see \fBnpm prefix \-g\fP for its value)\.
.P
Next, in some other location, \fBnpm link package\-name\fP will create a
symbolic link from globally\-installed \fBpackage\-name\fP to \fBnode_modules/\fP
of the current folder\.
.P
Note that \fBpackage\-name\fP is taken from \fBpackage\.json\fP,
not from directory name\.
.P
The package name can be optionally prefixed with a scope\. See npm help \fBscope\fP\|\.
The scope must be preceded by an @\-symbol and followed by a slash\.
.P
When creating tarballs for \fBnpm publish\fP, the linked packages are
"snapshotted" to their current state by resolving the symbolic links\.
.P
This is handy for installing your own stuff, so that you can work on it and
test it iteratively without having to continually rebuild\.
.P
For example:
.P
.RS 2
.nf
cd ~/projects/node\-redis # go into the package directory
npm link # creates global link
cd ~/projects/node\-bloggy # go into some other package directory\.
npm link redis # link\-install the package
.fi
.RE
.P
Now, any changes to ~/projects/node\-redis will be reflected in
~/projects/node\-bloggy/node_modules/node\-redis/\. Note that the link should
be to the package name, not the directory name for that package\.
.P
You may also shortcut the two steps in one\. For example, to do the
above use\-case in a shorter way:
.P
.RS 2
.nf
cd ~/projects/node\-bloggy # go into the dir of your main project
npm link \.\./node\-redis # link the dir of your dependency
.fi
.RE
.P
The second line is the equivalent of doing:
.P
.RS 2
.nf
(cd \.\./node\-redis; npm link)
npm link redis
.fi
.RE
.P
That is, it first creates a global link, and then links the global
installation target into your project's \fBnode_modules\fP folder\.
.P
Note that in this case, you are referring to the directory name, \fBnode\-redis\fP,
rather than the package name \fBredis\fP\|\.
.P
If your linked package is scoped (see npm help \fBscope\fP) your link command must include that scope, e\.g\.
.P
.RS 2
.nf
npm link @myorg/privatepackage
.fi
.RE
.SS See Also
.RS 0
.IP \(bu 2
npm help developers
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help install
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,52 @@
.TH "NPM\-LOGOUT" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-logout\fR \- Log out of the registry
.SS Synopsis
.P
.RS 2
.nf
npm logout [\-\-registry=<url>] [\-\-scope=<@scope>]
.fi
.RE
.SS Description
.P
When logged into a registry that supports token\-based authentication, tell the
server to end this token's session\. This will invalidate the token everywhere
you're using it, not just for the current environment\.
.P
When logged into a legacy registry that uses username and password authentication, this will
clear the credentials in your user configuration\. In this case, it will \fIonly\fR affect
the current environment\.
.P
If \fB\-\-scope\fP is provided, this will find the credentials for the registry
connected to that scope, if set\.
.SS Configuration
.SS registry
.P
Default: https://registry\.npmjs\.org/
.P
The base URL of the npm package registry\. If \fBscope\fP is also specified,
it takes precedence\.
.SS scope
.P
Default: The scope of your current project, if any, otherwise none\.
.P
If specified, you will be logged out of the specified scope\. See npm help \fBscope\fP\|\.
.P
.RS 2
.nf
npm logout \-\-scope=@myco
.fi
.RE
.SS See Also
.RS 0
.IP \(bu 2
npm help adduser
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help config
.IP \(bu 2
npm help whoami
.RE

View File

@ -0,0 +1,161 @@
.TH "NPM\-LS" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-ls\fR \- List installed packages
.SS Synopsis
.P
.RS 2
.nf
npm ls [[<@scope>/]<pkg> \.\.\.]
aliases: list, la, ll
.fi
.RE
.SS Description
.P
This command will print to stdout all the versions of packages that are
installed, as well as their dependencies, in a tree\-structure\.
.P
Positional arguments are \fBname@version\-range\fP identifiers, which will
limit the results to only the paths to the packages named\. Note that
nested packages will \fIalso\fR show the paths to the specified packages\.
For example, running \fBnpm ls promzard\fP in npm's source tree will show:
.P
.RS 2
.nf
npm@6\.14\.15 /path/to/npm
└─┬ init\-package\-json@0\.0\.4
└── promzard@0\.1\.5
.fi
.RE
.P
It will print out extraneous, missing, and invalid packages\.
.P
If a project specifies git urls for dependencies these are shown
in parentheses after the name@version to make it easier for users to
recognize potential forks of a project\.
.P
The tree shown is the logical dependency tree, based on package
dependencies, not the physical layout of your node_modules folder\.
.P
When run as \fBll\fP or \fBla\fP, it shows extended information by default\.
.SS Configuration
.SS json
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Show information in JSON format\.
.SS long
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Show extended information\.
.SS parseable
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Show parseable output instead of tree view\.
.SS global
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
List packages in the global install prefix instead of in the current
project\.
.SS depth
.RS 0
.IP \(bu 2
Type: Int
.RE
.P
Max display depth of the dependency tree\.
.SS prod / production
.RS 0
.IP \(bu 2
Type: Boolean
.IP \(bu 2
Default: false
.RE
.P
Display only the dependency tree for packages in \fBdependencies\fP\|\.
.SS dev / development
.RS 0
.IP \(bu 2
Type: Boolean
.IP \(bu 2
Default: false
.RE
.P
Display only the dependency tree for packages in \fBdevDependencies\fP\|\.
.SS only
.RS 0
.IP \(bu 2
Type: String
.RE
.P
When "dev" or "development", is an alias to \fBdev\fP\|\.
.P
When "prod" or "production", is an alias to \fBproduction\fP\|\.
.SS link
.RS 0
.IP \(bu 2
Type: Boolean
.IP \(bu 2
Default: false
.RE
.P
Display only dependencies which are linked
.SS unicode
.RS 0
.IP \(bu 2
Type: Boolean
.IP \(bu 2
Default: true
.RE
.P
Whether to represent the tree structure using unicode characters\.
Set it to false in order to use all\-ansi output\.
.SS See Also
.RS 0
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help install
.IP \(bu 2
npm help link
.IP \(bu 2
npm help prune
.IP \(bu 2
npm help outdated
.IP \(bu 2
npm help update
.RE

View File

@ -0,0 +1,72 @@
.TH "NPM\-ORG" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-org\fR \- Manage orgs
.SS Synopsis
.P
.RS 2
.nf
npm org set <orgname> <username> [developer | admin | owner]
npm org rm <orgname> <username>
npm org ls <orgname> [<username>]
.fi
.RE
.SS Example
.P
Add a new developer to an org:
.P
.RS 2
.nf
$ npm org set my\-org @mx\-smith
.fi
.RE
.P
Add a new admin to an org (or change a developer to an admin):
.P
.RS 2
.nf
$ npm org set my\-org @mx\-santos admin
.fi
.RE
.P
Remove a user from an org:
.P
.RS 2
.nf
$ npm org rm my\-org mx\-santos
.fi
.RE
.P
List all users in an org:
.P
.RS 2
.nf
$ npm org ls my\-org
.fi
.RE
.P
List all users in JSON format:
.P
.RS 2
.nf
$ npm org ls my\-org \-\-json
.fi
.RE
.P
See what role a user has in an org:
.P
.RS 2
.nf
$ npm org ls my\-org @mx\-santos
.fi
.RE
.SS Description
.P
You can use the \fBnpm org\fP commands to manage and view users of an organization\.
It supports adding and removing users, changing their roles, listing them, and
finding specific ones and their roles\.
.SS See Also
.RS 0
.IP \(bu 2
Documentation on npm Orgs \fIhttps://docs\.npmjs\.com/orgs/\fR
.RE

View File

@ -0,0 +1,156 @@
.TH "NPM\-OUTDATED" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-outdated\fR \- Check for outdated packages
.SS Synopsis
.P
.RS 2
.nf
npm outdated [[<@scope>/]<pkg> \.\.\.]
.fi
.RE
.SS Description
.P
This command will check the registry to see if any (or, specific) installed
packages are currently outdated\.
.P
In the output:
.RS 0
.IP \(bu 2
\fBwanted\fP is the maximum version of the package that satisfies the semver
range specified in \fBpackage\.json\fP\|\. If there's no available semver range (i\.e\.
you're running \fBnpm outdated \-\-global\fP, or the package isn't included in
\fBpackage\.json\fP), then \fBwanted\fP shows the currently\-installed version\.
.IP \(bu 2
\fBlatest\fP is the version of the package tagged as latest in the registry\.
Running \fBnpm publish\fP with no special configuration will publish the package
with a dist\-tag of \fBlatest\fP\|\. This may or may not be the maximum version of
the package, or the most\-recently published version of the package, depending
on how the package's developer manages the latest dist\-tag \fInpm\-dist\-tag\fR\|\.
.IP \(bu 2
\fBlocation\fP is where in the dependency tree the package is located\. Note that
\fBnpm outdated\fP defaults to a depth of 0, so unless you override that, you'll
always be seeing only top\-level dependencies that are outdated\.
.IP \(bu 2
\fBpackage type\fP (when using \fB\-\-long\fP / \fB\-l\fP) tells you whether this package is
a \fBdependency\fP or a \fBdevDependency\fP\|\. Packages not included in \fBpackage\.json\fP
are always marked \fBdependencies\fP\|\.
.IP \(bu 2
\fBhomepage\fP (when using \fB\-\-long\fP / \fB\-l\fP) is the \fBhomepage\fP value contained in the package's \fBpackage\.json\fP
.IP \(bu 2
Red means there's a newer version matching your semver requirements, so you should update now\.
.IP \(bu 2
Yellow indicates that there's a newer version above your semver requirements (usually new major, or new 0\.x minor) so proceed with caution\.
.RE
.SS An example
.P
.RS 2
.nf
$ npm outdated
Package Current Wanted Latest Location
glob 5\.0\.15 5\.0\.15 6\.0\.1 test\-outdated\-output
nothingness 0\.0\.3 git git test\-outdated\-output
npm 3\.5\.1 3\.5\.2 3\.5\.1 test\-outdated\-output
local\-dev 0\.0\.3 linked linked test\-outdated\-output
once 1\.3\.2 1\.3\.3 1\.3\.3 test\-outdated\-output
.fi
.RE
.P
With these \fBdependencies\fP:
.P
.RS 2
.nf
{
"glob": "^5\.0\.15",
"nothingness": "github:othiym23/nothingness#master",
"npm": "^3\.5\.1",
"once": "^1\.3\.1"
}
.fi
.RE
.P
A few things to note:
.RS 0
.IP \(bu 2
\fBglob\fP requires \fB^5\fP, which prevents npm from installing \fBglob@6\fP, which is
outside the semver range\.
.IP \(bu 2
Git dependencies will always be reinstalled, because of how they're specified\.
The installed committish might satisfy the dependency specifier (if it's
something immutable, like a commit SHA), or it might not, so \fBnpm outdated\fP and
\fBnpm update\fP have to fetch Git repos to check\. This is why currently doing a
reinstall of a Git dependency always forces a new clone and install\.
.IP \(bu 2
\fBnpm@3\.5\.2\fP is marked as "wanted", but "latest" is \fBnpm@3\.5\.1\fP because npm
uses dist\-tags to manage its \fBlatest\fP and \fBnext\fP release channels\. \fBnpm update\fP
will install the \fInewest\fR version, but \fBnpm install npm\fP (with no semver range)
will install whatever's tagged as \fBlatest\fP\|\.
.IP \(bu 2
\fBonce\fP is just plain out of date\. Reinstalling \fBnode_modules\fP from scratch or
running \fBnpm update\fP will bring it up to spec\.
.RE
.SS Configuration
.SS json
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Show information in JSON format\.
.SS long
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Show extended information\.
.SS parseable
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Show parseable output instead of tree view\.
.SS global
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Check packages in the global install prefix instead of in the current
project\.
.SS depth
.RS 0
.IP \(bu 2
Default: 0
.IP \(bu 2
Type: Int
.RE
.P
Max depth for checking dependency tree\.
.SS See Also
.RS 0
.IP \(bu 2
npm help update
.IP \(bu 2
npm help dist\-tag
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help folders
.RE

View File

@ -0,0 +1,52 @@
.TH "NPM\-OWNER" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-owner\fR \- Manage package owners
.SS Synopsis
.P
.RS 2
.nf
npm owner add <user> [<@scope>/]<pkg>
npm owner rm <user> [<@scope>/]<pkg>
npm owner ls [<@scope>/]<pkg>
aliases: author
.fi
.RE
.SS Description
.P
Manage ownership of published packages\.
.RS 0
.IP \(bu 2
ls:
List all the users who have access to modify a package and push new versions\.
Handy when you need to know who to bug for help\.
.IP \(bu 2
add:
Add a new user as a maintainer of a package\. This user is enabled to modify
metadata, publish new versions, and add other owners\.
.IP \(bu 2
rm:
Remove a user from the package owner list\. This immediately revokes their
privileges\.
.RE
.P
Note that there is only one level of access\. Either you can modify a package,
or you can't\. Future versions may contain more fine\-grained access levels, but
that is not implemented at this time\.
.P
If you have two\-factor authentication enabled with \fBauth\-and\-writes\fP then
you'll need to include an otp on the command line when changing ownership
with \fB\-\-otp\fP\|\.
.SS See Also
.RS 0
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help adduser
.IP \(bu 2
npm help disputes
.RE

View File

@ -0,0 +1,37 @@
.TH "NPM\-PACK" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-pack\fR \- Create a tarball from a package
.SS Synopsis
.P
.RS 2
.nf
npm pack [[<@scope>/]<pkg>\.\.\.] [\-\-dry\-run]
.fi
.RE
.SS Description
.P
For anything that's installable (that is, a package folder, tarball,
tarball url, name@tag, name@version, name, or scoped name), this
command will fetch it to the cache, and then copy the tarball to the
current working directory as \fB<name>\-<version>\.tgz\fP, and then write
the filenames out to stdout\.
.P
If the same package is specified multiple times, then the file will be
overwritten the second time\.
.P
If no arguments are supplied, then npm packs the current package folder\.
.P
The \fB\-\-dry\-run\fP argument will do everything that pack usually does without
actually packing anything\. Reports on what would have gone into the tarball\.
.SS See Also
.RS 0
.IP \(bu 2
npm help cache
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,36 @@
.TH "NPM\-PING" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-ping\fR \- Ping npm registry
.SS Synopsis
.P
.RS 2
.nf
npm ping [\-\-registry <registry>]
.fi
.RE
.SS Description
.P
Ping the configured or given npm registry and verify authentication\.
If it works it will output something like:
.P
.RS 2
.nf
Ping success: {*Details about registry*}
.fi
.RE
.P
otherwise you will get:
.P
.RS 2
.nf
Ping error: {*Detail about error}
.fi
.RE
.SS See Also
.RS 0
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,32 @@
.TH "NPM\-PREFIX" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-prefix\fR \- Display prefix
.SS Synopsis
.P
.RS 2
.nf
npm prefix [\-g]
.fi
.RE
.SS Description
.P
Print the local prefix to standard out\. This is the closest parent directory
to contain a \fBpackage\.json\fP file or \fBnode_modules\fP directory, unless \fB\-g\fP is
also specified\.
.P
If \fB\-g\fP is specified, this will be the value of the global prefix\. See
npm help \fBconfig\fP for more detail\.
.SS See Also
.RS 0
.IP \(bu 2
npm help root
.IP \(bu 2
npm help bin
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,91 @@
.TH "NPM\-PROFILE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-profile\fR \- Change settings on your registry profile
.SS Synopsis
.P
.RS 2
.nf
npm profile get [\-\-json|\-\-parseable] [<property>]
npm profile set [\-\-json|\-\-parseable] <property> <value>
npm profile set password
npm profile enable\-2fa [auth\-and\-writes|auth\-only]
npm profile disable\-2fa
.fi
.RE
.SS Description
.P
Change your profile information on the registry\. This not be available if
you're using a non\-npmjs registry\.
.RS 0
.IP \(bu 2
\fBnpm profile get [<property>]\fP:
Display all of the properties of your profile, or one or more specific
properties\. It looks like:
.RE
.P
.RS 2
.nf
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| name | example |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| email | me@example\.com (verified) |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| two factor auth | auth\-and\-writes |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| fullname | Example User |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| homepage | |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| freenode | |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| twitter | |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| github | |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| created | 2015\-02\-26T01:38:35\.892Z |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| updated | 2017\-10\-02T21:29:45\.922Z |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
.fi
.RE
.RS 0
.IP \(bu 2
\fBnpm profile set <property> <value>\fP:
Set the value of a profile property\. You can set the following properties this way:
email, fullname, homepage, freenode, twitter, github
.IP \(bu 2
\fBnpm profile set password\fP:
Change your password\. This is interactive, you'll be prompted for your
current password and a new password\. You'll also be prompted for an OTP
if you have two\-factor authentication enabled\.
.IP \(bu 2
\fBnpm profile enable\-2fa [auth\-and\-writes|auth\-only]\fP:
Enables two\-factor authentication\. Defaults to \fBauth\-and\-writes\fP mode\. Modes are:
.RS
.IP \(bu 2
\fBauth\-only\fP: Require an OTP when logging in or making changes to your
account's authentication\. The OTP will be required on both the website
and the command line\.
.IP \(bu 2
\fBauth\-and\-writes\fP: Requires an OTP at all the times \fBauth\-only\fP does, and also requires one when
publishing a module, setting the \fBlatest\fP dist\-tag, or changing access
via \fBnpm access\fP and \fBnpm owner\fP\|\.
.RE
.IP \(bu 2
\fBnpm profile disable\-2fa\fP:
Disables two\-factor authentication\.
.RE
.SS Details
.P
All of the \fBnpm profile\fP subcommands accept \fB\-\-json\fP and \fB\-\-parseable\fP and
will tailor their output based on those\. Some of these commands may not be
available on non npmjs\.com registries\.
.SS See Also
.RS 0
.IP \(bu 2
npm help config
.RE

View File

@ -0,0 +1,45 @@
.TH "NPM\-PRUNE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-prune\fR \- Remove extraneous packages
.SS Synopsis
.P
.RS 2
.nf
npm prune [[<@scope>/]<pkg>\.\.\.] [\-\-production] [\-\-dry\-run] [\-\-json]
.fi
.RE
.SS Description
.P
This command removes "extraneous" packages\. If a package name is
provided, then only packages matching one of the supplied names are
removed\.
.P
Extraneous packages are packages that are not listed on the parent
package's dependencies list\.
.P
If the \fB\-\-production\fP flag is specified or the \fBNODE_ENV\fP environment
variable is set to \fBproduction\fP, this command will remove the packages
specified in your \fBdevDependencies\fP\|\. Setting \fB\-\-no\-production\fP will
negate \fBNODE_ENV\fP being set to \fBproduction\fP\|\.
.P
If the \fB\-\-dry\-run\fP flag is used then no changes will actually be made\.
.P
If the \fB\-\-json\fP flag is used then the changes \fBnpm prune\fP made (or would
have made with \fB\-\-dry\-run\fP) are printed as a JSON object\.
.P
In normal operation with package\-locks enabled, extraneous modules are
pruned automatically when modules are installed and you'll only need
this command with the \fB\-\-production\fP flag\.
.P
If you've disabled package\-locks then extraneous modules will not be removed
and it's up to you to run \fBnpm prune\fP from time\-to\-time to remove them\.
.SS See Also
.RS 0
.IP \(bu 2
npm help uninstall
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help ls
.RE

View File

@ -0,0 +1,88 @@
.TH "NPM\-PUBLISH" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-publish\fR \- Publish a package
.SS Synopsis
.P
.RS 2
.nf
npm publish [<tarball>|<folder>] [\-\-tag <tag>] [\-\-access <public|restricted>] [\-\-otp otpcode] [\-\-dry\-run]
Publishes '\.' if no argument supplied
Sets tag 'latest' if no \-\-tag specified
.fi
.RE
.SS Description
.P
Publishes a package to the registry so that it can be installed by name\. All
files in the package directory are included if no local \fB\|\.gitignore\fP or
\fB\|\.npmignore\fP file exists\. If both files exist and a file is ignored by
\fB\|\.gitignore\fP but not by \fB\|\.npmignore\fP then it will be included\. See
npm help \fBdevelopers\fP for full details on what's included in the published package, as well as details on how the package is built\.
.P
By default npm will publish to the public registry\. This can be overridden by
specifying a different default registry or using a npm help \fBscope\fP in the name (see npm help \fBpackage\.json\fP)\.
.RS 0
.IP \(bu 2
\fB<folder>\fP:
A folder containing a package\.json file
.IP \(bu 2
\fB<tarball>\fP:
A url or file path to a gzipped tar archive containing a single folder
with a package\.json file inside\.
.IP \(bu 2
\fB[\-\-tag <tag>]\fP
Registers the published package with the given tag, such that \fBnpm install
<name>@<tag>\fP will install this version\. By default, \fBnpm publish\fP updates
and \fBnpm install\fP installs the \fBlatest\fP tag\. See \fBnpm\-dist\-tag\fP \fInpm\-dist\-tag\fR for
details about tags\.
.IP \(bu 2
\fB[\-\-access <public|restricted>]\fP
Tells the registry whether this package should be published as public or
restricted\. Only applies to scoped packages, which default to \fBrestricted\fP\|\.
If you don't have a paid account, you must publish with \fB\-\-access public\fP
to publish scoped packages\.
.IP \(bu 2
\fB[\-\-otp <otpcode>]\fP
If you have two\-factor authentication enabled in \fBauth\-and\-writes\fP mode
then you can provide a code from your authenticator with this\. If you
don't include this and you're running from a TTY then you'll be prompted\.
.IP \(bu 2
\fB[\-\-dry\-run]\fP
As of \fBnpm@6\fP, does everything publish would do except actually publishing
to the registry\. Reports the details of what would have been published\.
.RE
.P
Fails if the package name and version combination already exists in
the specified registry\.
.P
Once a package is published with a given name and version, that
specific name and version combination can never be used again, even if
it is removed with npm help \fBunpublish\fP\|\.
.P
As of \fBnpm@5\fP, both a sha1sum and an integrity field with a sha512sum of the
tarball will be submitted to the registry during publication\. Subsequent
installs will use the strongest supported algorithm to verify downloads\.
.P
Similar to \fB\-\-dry\-run\fP see npm help \fBpack\fP, which figures out the files to be
included and packs them into a tarball to be uploaded to the registry\.
.SS See Also
.RS 0
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help scope
.IP \(bu 2
npm help adduser
.IP \(bu 2
npm help owner
.IP \(bu 2
npm help deprecate
.IP \(bu 2
npm help dist\-tag
.IP \(bu 2
npm help pack
.IP \(bu 2
npm help profile
.RE

View File

@ -0,0 +1,23 @@
.TH "NPM\-REBUILD" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-rebuild\fR \- Rebuild a package
.SS Synopsis
.P
.RS 2
.nf
npm rebuild [[<@scope>/<name>]\.\.\.]
alias: npm rb
.fi
.RE
.SS Description
.P
This command runs the \fBnpm build\fP command on the matched folders\. This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary\.
.SS See Also
.RS 0
.IP \(bu 2
npm help build
.IP \(bu 2
npm help install
.RE

View File

@ -0,0 +1,35 @@
.TH "NPM\-REPO" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-repo\fR \- Open package repository page in the browser
.SS Synopsis
.P
.RS 2
.nf
npm repo [<pkg>]
.fi
.RE
.SS Description
.P
This command tries to guess at the likely location of a package's
repository URL, and then tries to open it using the \fB\-\-browser\fP
config param\. If no package name is provided, it will search for
a \fBpackage\.json\fP in the current folder and use the \fBname\fP property\.
.SS Configuration
.SS browser
.RS 0
.IP \(bu 2
Default: OS X: \fB"open"\fP, Windows: \fB"start"\fP, Others: \fB"xdg\-open"\fP
.IP \(bu 2
Type: String
.RE
.P
The browser that is called by the \fBnpm repo\fP command to open websites\.
.SS See Also
.RS 0
.IP \(bu 2
npm help docs
.IP \(bu 2
npm help config
.RE

View File

@ -0,0 +1,60 @@
.TH "NPM\-RESTART" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-restart\fR \- Restart a package
.SS Synopsis
.P
.RS 2
.nf
npm restart [\-\- <args>]
.fi
.RE
.SS Description
.P
This restarts a package\.
.P
This runs a package's "stop", "restart", and "start" scripts, and associated
pre\- and post\- scripts, in the order given below:
.RS 0
.IP 1. 3
prerestart
.IP 2. 3
prestop
.IP 3. 3
stop
.IP 4. 3
poststop
.IP 5. 3
restart
.IP 6. 3
prestart
.IP 7. 3
start
.IP 8. 3
poststart
.IP 9. 3
postrestart
.RE
.SS Note
.P
Note that the "restart" script is run \fBin addition to\fR the "stop"
and "start" scripts, not instead of them\.
.P
This is the behavior as of \fBnpm\fP major version 2\. A change in this
behavior will be accompanied by an increase in major version number
.SS See Also
.RS 0
.IP \(bu 2
npm help run\-script
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help test
.IP \(bu 2
npm help start
.IP \(bu 2
npm help stop
.IP \(bu 2
npm help restart
.RE

View File

@ -0,0 +1,27 @@
.TH "NPM\-ROOT" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-root\fR \- Display npm root
.SS Synopsis
.P
.RS 2
.nf
npm root [\-g]
.fi
.RE
.SS Description
.P
Print the effective \fBnode_modules\fP folder to standard out\.
.SS See Also
.RS 0
.IP \(bu 2
npm help prefix
.IP \(bu 2
npm help bin
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,104 @@
.TH "NPM\-RUN\-SCRIPT" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-run-script\fR \- Run arbitrary package scripts
.SS Synopsis
.P
.RS 2
.nf
npm run\-script <command> [\-\-silent] [\-\- <args>\.\.\.]
alias: npm run
.fi
.RE
.SS Description
.P
This runs an arbitrary command from a package's \fB"scripts"\fP object\. If no
\fB"command"\fP is provided, it will list the available scripts\. \fBrun[\-script]\fP is
used by the test, start, restart, and stop commands, but can be called
directly, as well\. When the scripts in the package are printed out, they're
separated into lifecycle (test, start, restart) and directly\-run scripts\.
.P
As of \fBnpm@2\.0\.0\fP \fIhttps://blog\.npmjs\.org/post/98131109725/npm\-2\-0\-0\fR, you can
use custom arguments when executing scripts\. The special option \fB\-\-\fP is used by
getopt \fIhttps://goo\.gl/KxMmtG\fR to delimit the end of the options\. npm will pass
all the arguments after the \fB\-\-\fP directly to your script:
.P
.RS 2
.nf
npm run test \-\- \-\-grep="pattern"
.fi
.RE
.P
The arguments will only be passed to the script specified after \fBnpm run\fP
and not to any pre or post script\.
.P
The \fBenv\fP script is a special built\-in command that can be used to list
environment variables that will be available to the script at runtime\. If an
"env" command is defined in your package, it will take precedence over the
built\-in\.
.P
In addition to the shell's pre\-existing \fBPATH\fP, \fBnpm run\fP adds
\fBnode_modules/\.bin\fP to the \fBPATH\fP provided to scripts\. Any binaries provided by
locally\-installed dependencies can be used without the \fBnode_modules/\.bin\fP
prefix\. For example, if there is a \fBdevDependency\fP on \fBtap\fP in your package,
you should write:
.P
.RS 2
.nf
"scripts": {"test": "tap test/\\*\.js"}
.fi
.RE
.P
instead of
.P
.RS 2
.nf
"scripts": {"test": "node_modules/\.bin/tap test/\\*\.js"}
.fi
.RE
.P
to run your tests\.
.P
The actual shell your script is run within is platform dependent\. By default,
on Unix\-like systems it is the \fB/bin/sh\fP command, on Windows it is the \fBcmd\.exe\fP\|\.
The actual shell referred to by \fB/bin/sh\fP also depends on the system\.
As of \fBnpm@5\.1\.0\fP \fIhttps://github\.com/npm/npm/releases/tag/v5\.1\.0\fR you can
customize the shell with the \fBscript\-shell\fP configuration\.
.P
Scripts are run from the root of the module, regardless of what your current
working directory is when you call \fBnpm run\fP\|\. If you want your script to
use different behavior based on what subdirectory you're in, you can use the
\fBINIT_CWD\fP environment variable, which holds the full path you were in when
you ran \fBnpm run\fP\|\.
.P
\fBnpm run\fP sets the \fBNODE\fP environment variable to the \fBnode\fP executable with
which \fBnpm\fP is executed\. Also, if the \fB\-\-scripts\-prepend\-node\-path\fP is passed,
the directory within which \fBnode\fP resides is added to the
\fBPATH\fP\|\. If \fB\-\-scripts\-prepend\-node\-path=auto\fP is passed (which has been the
default in \fBnpm\fP v3), this is only performed when that \fBnode\fP executable is
not found in the \fBPATH\fP\|\.
.P
If you try to run a script without having a \fBnode_modules\fP directory and it fails,
you will be given a warning to run \fBnpm install\fP, just in case you've forgotten\.
.P
You can use the \fB\-\-silent\fP flag to prevent showing \fBnpm ERR!\fP output on error\.
.P
You can use the \fB\-\-if\-present\fP flag to avoid exiting with a non\-zero exit code
when the script is undefined\. This lets you run potentially undefined scripts
without breaking the execution chain\.
.SS See Also
.RS 0
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help test
.IP \(bu 2
npm help start
.IP \(bu 2
npm help restart
.IP \(bu 2
npm help stop
.IP \(bu 2
npm help config
.RE

View File

@ -0,0 +1,135 @@
.TH "NPM\-SEARCH" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-search\fR \- Search for packages
.SS Synopsis
.P
.RS 2
.nf
npm search [\-l|\-\-long] [\-\-json] [\-\-parseable] [\-\-no\-description] [search terms \.\.\.]
aliases: s, se, find
.fi
.RE
.SS Description
.P
Search the registry for packages matching the search terms\. \fBnpm search\fP
performs a linear, incremental, lexically\-ordered search through package
metadata for all files in the registry\. If color is enabled, it will further
highlight the matches in the results\.
.P
Additionally, using the \fB\-\-searchopts\fP and \fB\-\-searchexclude\fP options paired with
more search terms will respectively include and exclude further patterns\. The
main difference between \fB\-\-searchopts\fP and the standard search terms is that the
former does not highlight results in the output and can be used for more
fine\-grained filtering\. Additionally, both of these can be added to \fB\|\.npmrc\fP for
default search filtering behavior\.
.P
Search also allows targeting of maintainers in search results, by prefixing
their npm username with \fB=\fP\|\.
.P
If a term starts with \fB/\fP, then it's interpreted as a regular expression and
supports standard JavaScript RegExp syntax\. A trailing \fB/\fP will be ignored in
this case\. (Note that many regular expression characters must be escaped or
quoted in most shells\.)
.SS A Note on caching
.SS Configuration
.SS description
.RS 0
.IP \(bu 2
Default: true
.IP \(bu 2
Type: Boolean
.RE
.P
Used as \fB\-\-no\-description\fP, disables search matching in package descriptions and
suppresses display of that field in results\.
.SS json
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Output search results as a JSON array\.
.SS parseable
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Output search results as lines with tab\-separated columns\.
.SS long
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Display full package descriptions and other long text across multiple
lines\. When disabled (default) search results are truncated to fit
neatly on a single line\. Modules with extremely long names will
fall on multiple lines\.
.SS searchopts
.RS 0
.IP \(bu 2
Default: ""
.IP \(bu 2
Type: String
.RE
.P
Space\-separated options that are always passed to search\.
.SS searchexclude
.RS 0
.IP \(bu 2
Default: ""
.IP \(bu 2
Type: String
.RE
.P
Space\-separated options that limit the results from search\.
.SS searchstaleness
.RS 0
.IP \(bu 2
Default: 900 (15 minutes)
.IP \(bu 2
Type: Number
.RE
.P
The age of the cache, in seconds, before another registry request is made\.
.SS registry
.RS 0
.IP \(bu 2
Default: https://registry\.npmjs\.org/
.IP \(bu 2
Type: url
.RE
.P
Search the specified registry for modules\. If you have configured npm to point
to a different default registry, such as your internal private module
repository, \fBnpm search\fP will default to that registry when searching\. Pass a
different registry url such as the default above in order to override this
setting\.
.SS See Also
.RS 0
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help view
.RE

View File

@ -0,0 +1,37 @@
.TH "NPM\-SHRINKWRAP" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-shrinkwrap\fR \- Lock down dependency versions for publication
.SS Synopsis
.P
.RS 2
.nf
npm shrinkwrap
.fi
.RE
.SS Description
.P
This command repurposes \fBpackage\-lock\.json\fP into a publishable
\fBnpm\-shrinkwrap\.json\fP or simply creates a new one\. The file created and updated
by this command will then take precedence over any other existing or future
\fBpackage\-lock\.json\fP files\. For a detailed explanation of the design and purpose
of package locks in npm, see npm help package\-locks\.
.SS See Also
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help run\-script
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help package\.js
.IP \(bu 2
npm help package\-locks
.IP \(bu 2
npm help package\-lock\.json
.IP \(bu 2
npm help shrinkwrap\.json
.IP \(bu 2
npm help ls
.RE

View File

@ -0,0 +1,29 @@
.TH "NPM\-STAR" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-star\fR \- Mark your favorite packages
.SS Synopsis
.P
.RS 2
.nf
npm star [<pkg>\.\.\.]
npm unstar [<pkg>\.\.\.]
.fi
.RE
.SS Description
.P
"Starring" a package means that you have some interest in it\. It's
a vaguely positive way to show that you care\.
.P
"Unstarring" is the same thing, but in reverse\.
.P
It's a boolean thing\. Starring repeatedly has no additional effect\.
.SS See Also
.RS 0
.IP \(bu 2
npm help view
.IP \(bu 2
npm help whoami
.IP \(bu 2
npm help adduser
.RE

View File

@ -0,0 +1,29 @@
.TH "NPM\-STARS" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-stars\fR \- View packages marked as favorites
.SS Synopsis
.P
.RS 2
.nf
npm stars [<user>]
.fi
.RE
.SS Description
.P
If you have starred a lot of neat things and want to find them again
quickly this command lets you do just that\.
.P
You may also want to see your friend's favorite packages, in this case
you will most certainly enjoy this command\.
.SS See Also
.RS 0
.IP \(bu 2
npm help star
.IP \(bu 2
npm help view
.IP \(bu 2
npm help whoami
.IP \(bu 2
npm help adduser
.RE

View File

@ -0,0 +1,32 @@
.TH "NPM\-START" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-start\fR \- Start a package
.SS Synopsis
.P
.RS 2
.nf
npm start [\-\- <args>]
.fi
.RE
.SS Description
.P
This runs an arbitrary command specified in the package's \fB"start"\fP property of
its \fB"scripts"\fP object\. If no \fB"start"\fP property is specified on the
\fB"scripts"\fP object, it will run \fBnode server\.js\fP\|\.
.P
As of \fBnpm@2\.0\.0\fP \fIhttps://blog\.npmjs\.org/post/98131109725/npm\-2\-0\-0\fR, you can
use custom arguments when executing scripts\. Refer to npm help \fBrun\-script\fP for more details\.
.SS See Also
.RS 0
.IP \(bu 2
npm help run\-script
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help test
.IP \(bu 2
npm help restart
.IP \(bu 2
npm help stop
.RE

View File

@ -0,0 +1,27 @@
.TH "NPM\-STOP" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-stop\fR \- Stop a package
.SS Synopsis
.P
.RS 2
.nf
npm stop [\-\- <args>]
.fi
.RE
.SS Description
.P
This runs a package's "stop" script, if one was provided\.
.SS See Also
.RS 0
.IP \(bu 2
npm help run\-script
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help test
.IP \(bu 2
npm help start
.IP \(bu 2
npm help restart
.RE

View File

@ -0,0 +1,66 @@
.TH "NPM\-TEAM" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-team\fR \- Manage organization teams and team memberships
.SS Synopsis
.P
.RS 2
.nf
npm team create <scope:team>
npm team destroy <scope:team>
npm team add <scope:team> <user>
npm team rm <scope:team> <user>
npm team ls <scope>|<scope:team>
npm team edit <scope:team>
.fi
.RE
.SS Description
.P
Used to manage teams in organizations, and change team memberships\. Does not
handle permissions for packages\.
.P
Teams must always be fully qualified with the organization/scope they belong to
when operating on them, separated by a colon (\fB:\fP)\. That is, if you have a \fBwombats\fP team in a \fBwisdom\fP organization, you must always refer to that team as \fBwisdom:wombats\fP in these commands\.
.P
If you have two\-factor authentication enabled in \fBauth\-and\-writes\fP mode, then you can provide a code from your authenticator with \fB[\-\-otp <otpcode>]\fP\|\. If you don't include this then you will be prompted\.
.RS 0
.IP \(bu 2
create / destroy:
Create a new team, or destroy an existing one\. Note: You cannot remove the \fBdevelopers\fP team, <a href="https://docs\.npmjs\.com/about\-developers\-team" target="_blank">learn more\.</a>
.IP \(bu 2
add / rm:
Add a user to an existing team, or remove a user from a team they belong to\.
.IP \(bu 2
ls:
If performed on an organization name, will return a list of existing teams
under that organization\. If performed on a team, it will instead return a list
of all users belonging to that particular team\.
.IP \(bu 2
edit:
Edit a current team\.
.RE
.SS Details
.P
\fBnpm team\fP always operates directly on the current registry, configurable from
the command line using \fB\-\-registry=<registry url>\fP\|\.
.P
In order to create teams and manage team membership, you must be a \fIteam admin\fR
under the given organization\. Listing teams and team memberships may be done by
any member of the organizations\.
.P
Organization creation and management of team admins and \fIorganization\fR members
is done through the website, not the npm CLI\.
.P
To use teams to manage permissions on packages belonging to your organization,
use the \fBnpm access\fP command to grant or revoke the appropriate permissions\.
.SS See Also
.RS 0
.IP \(bu 2
npm help access
.IP \(bu 2
npm help registry
.RE

View File

@ -0,0 +1,29 @@
.TH "NPM\-TEST" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-test\fR \- Test a package
.SS Synopsis
.P
.RS 2
.nf
npm test [\-\- <args>]
aliases: t, tst
.fi
.RE
.SS Description
.P
This runs a package's "test" script, if one was provided\.
.SS See Also
.RS 0
.IP \(bu 2
npm help run\-script
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help start
.IP \(bu 2
npm help restart
.IP \(bu 2
npm help stop
.RE

View File

@ -0,0 +1,76 @@
.TH "NPM\-TOKEN" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-token\fR \- Manage your authentication tokens
.SS Synopsis
.P
.RS 2
.nf
npm token list [\-\-json|\-\-parseable]
npm token create [\-\-read\-only] [\-\-cidr=1\.1\.1\.1/24,2\.2\.2\.2/16]
npm token revoke <id|token>
.fi
.RE
.SS Description
.P
This lets you list, create and revoke authentication tokens\.
.RS 0
.IP \(bu 2
\fBnpm token list\fP:
Shows a table of all active authentication tokens\. You can request this as
JSON with \fB\-\-json\fP or tab\-separated values with \fB\-\-parseable\fP\|\.
.RE
.P
.RS 2
.nf
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| id | token | created | read\-only | CIDR whitelist |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| 7f3134 | 1fa9ba… | 2017\-10\-02 | yes | |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| c03241 | af7aef… | 2017\-10\-02 | no | 192\.168\.0\.1/24 |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| e0cf92 | 3a436a… | 2017\-10\-02 | no | |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| 63eb9d | 74ef35… | 2017\-09\-28 | no | |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| 2daaa8 | cbad5f… | 2017\-09\-26 | no | |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| 68c2fe | 127e51… | 2017\-09\-23 | no | |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| 6334e1 | 1dadd1… | 2017\-09\-23 | no | |
+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
.fi
.RE
.RS 0
.IP \(bu 2
\fBnpm token create [\-\-read\-only] [\-\-cidr=<cidr\-ranges>]\fP:
Create a new authentication token\. It can be \fB\-\-read\-only\fP or accept a list of
CIDR \fIhttps://en\.wikipedia\.org/wiki/Classless_Inter\-Domain_Routing\fR ranges to
limit use of this token to\. This will prompt you for your password, and, if you have
two\-factor authentication enabled, an otp\.
.RE
.P
.RS 2
.nf
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| token | a73c9572\-f1b9\-8983\-983d\-ba3ac3cc913d |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| cidr_whitelist | |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| readonly | false |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| created | 2017\-10\-02T07:52:24\.838Z |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
.fi
.RE
.RS 0
.IP \(bu 2
\fBnpm token revoke <token|id>\fP:
This removes an authentication token, making it immediately unusable\. This can accept
both complete tokens (as you get back from \fBnpm token create\fP and will
find in your \fB\|\.npmrc\fP) and ids as seen in the \fBnpm token list\fP output\.
This will NOT accept the truncated token found in \fBnpm token list\fP output\.
.RE

View File

@ -0,0 +1,72 @@
.TH "NPM\-UNINSTALL" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-uninstall\fR \- Remove a package
.SS Synopsis
.P
.RS 2
.nf
npm uninstall [<@scope>/]<pkg>[@<version>]\.\.\. [\-S|\-\-save|\-D|\-\-save\-dev|\-O|\-\-save\-optional|\-\-no\-save]
aliases: remove, rm, r, un, unlink
.fi
.RE
.SS Description
.P
This uninstalls a package, completely removing everything npm installed
on its behalf\.
.P
Example:
.P
.RS 2
.nf
npm uninstall sax
.fi
.RE
.P
In global mode (ie, with \fB\-g\fP or \fB\-\-global\fP appended to the command),
it uninstalls the current package context as a global package\.
.P
\fBnpm uninstall\fP takes 3 exclusive, optional flags which save or update
the package version in your main package\.json:
.RS 0
.IP \(bu 2
\fB\-S, \-\-save\fP: Package will be removed from your \fBdependencies\fP\|\.
.IP \(bu 2
\fB\-D, \-\-save\-dev\fP: Package will be removed from your \fBdevDependencies\fP\|\.
.IP \(bu 2
\fB\-O, \-\-save\-optional\fP: Package will be removed from your \fBoptionalDependencies\fP\|\.
.IP \(bu 2
\fB\-\-no\-save\fP: Package will not be removed from your \fBpackage\.json\fP file\.
.RE
.P
Further, if you have an \fBnpm\-shrinkwrap\.json\fP then it will be updated as
well\.
.P
Scope is optional and follows the usual rules for npm help \fBscope\fP\|\.
.P
Examples:
.P
.RS 2
.nf
npm uninstall sax \-\-save
npm uninstall @myorg/privatepackage \-\-save
npm uninstall node\-tap \-\-save\-dev
npm uninstall dtrace\-provider \-\-save\-optional
npm uninstall lodash \-\-no\-save
.fi
.RE
.SS See Also
.RS 0
.IP \(bu 2
npm help prune
.IP \(bu 2
npm help install
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,48 @@
.TH "NPM\-UNPUBLISH" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-unpublish\fR \- Remove a package from the registry
.SS Synopsis
.SS Unpublishing a single version of a package
.P
.RS 2
.nf
npm unpublish [<@scope>/]<pkg>@<version>
.fi
.RE
.SS Unpublishing an entire package
.P
.RS 2
.nf
npm unpublish [<@scope>/]<pkg> \-\-force
.fi
.RE
.SS Warning
.P
Consider using the \fBdeprecate\fP command instead, if your intent is to encourage users to upgrade, or if you no longer want to maintain a package\.
.SS Description
.P
This removes a package version from the registry, deleting its
entry and removing the tarball\.
.P
If no version is specified, or if all versions are removed then
the root package entry is removed from the registry entirely\.
.P
Even if a package version is unpublished, that specific name and
version combination can never be reused\. In order to publish the
package again, a new version number must be used\. If you unpublish the entire package, you may not publish any new versions of that package until 24 hours have passed\.
.P
To learn more about how unpublish is treated on the npm registry, see our <a href="https://www\.npmjs\.com/policies/unpublish" target="_blank" rel="noopener noreferrer"> unpublish policies</a>\|\.
.SS See Also
.RS 0
.IP \(bu 2
npm help deprecate
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help adduser
.IP \(bu 2
npm help owner
.RE

View File

@ -0,0 +1,144 @@
.TH "NPM\-UPDATE" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-update\fR \- Update a package
.SS Synopsis
.P
.RS 2
.nf
npm update [\-g] [<pkg>\.\.\.]
aliases: up, upgrade
.fi
.RE
.SS Description
.P
This command will update all the packages listed to the latest version
(specified by the \fBtag\fP config), respecting semver\.
.P
It will also install missing packages\. As with all commands that install
packages, the \fB\-\-dev\fP flag will cause \fBdevDependencies\fP to be processed
as well\.
.P
If the \fB\-g\fP flag is specified, this command will update globally installed
packages\.
.P
If no package name is specified, all packages in the specified location (global
or local) will be updated\.
.P
As of \fBnpm@2\.6\.1\fP, the \fBnpm update\fP will only inspect top\-level packages\.
Prior versions of \fBnpm\fP would also recursively inspect all dependencies\.
To get the old behavior, use \fBnpm \-\-depth 9999 update\fP\|\.
.P
As of \fBnpm@5\.0\.0\fP, the \fBnpm update\fP will change \fBpackage\.json\fP to save the
new version as the minimum required dependency\. To get the old behavior,
use \fBnpm update \-\-no\-save\fP\|\.
.SS Example
.P
IMPORTANT VERSION NOTE: these examples assume \fBnpm@2\.6\.1\fP or later\. For
older versions of \fBnpm\fP, you must specify \fB\-\-depth 0\fP to get the behavior
described below\.
.P
For the examples below, assume that the current package is \fBapp\fP and it depends
on dependencies, \fBdep1\fP (\fBdep2\fP, \.\. etc\.)\. The published versions of \fBdep1\fP are:
.P
.RS 2
.nf
{
"dist\-tags": { "latest": "1\.2\.2" },
"versions": [
"1\.2\.2",
"1\.2\.1",
"1\.2\.0",
"1\.1\.2",
"1\.1\.1",
"1\.0\.0",
"0\.4\.1",
"0\.4\.0",
"0\.2\.0"
]
}
.fi
.RE
.SS Caret Dependencies
.P
If \fBapp\fP\|'s \fBpackage\.json\fP contains:
.P
.RS 2
.nf
"dependencies": {
"dep1": "^1\.1\.1"
}
.fi
.RE
.P
Then \fBnpm update\fP will install \fBdep1@1\.2\.2\fP, because \fB1\.2\.2\fP is \fBlatest\fP and
\fB1\.2\.2\fP satisfies \fB^1\.1\.1\fP\|\.
.SS Tilde Dependencies
.P
However, if \fBapp\fP\|'s \fBpackage\.json\fP contains:
.P
.RS 2
.nf
"dependencies": {
"dep1": "~1\.1\.1"
}
.fi
.RE
.P
In this case, running \fBnpm update\fP will install \fBdep1@1\.1\.2\fP\|\. Even though the \fBlatest\fP
tag points to \fB1\.2\.2\fP, this version does not satisfy \fB~1\.1\.1\fP, which is equivalent
to \fB>=1\.1\.1 <1\.2\.0\fP\|\. So the highest\-sorting version that satisfies \fB~1\.1\.1\fP is used,
which is \fB1\.1\.2\fP\|\.
.SS Caret Dependencies below 1\.0\.0
.P
Suppose \fBapp\fP has a caret dependency on a version below \fB1\.0\.0\fP, for example:
.P
.RS 2
.nf
"dependencies": {
"dep1": "^0\.2\.0"
}
.fi
.RE
.P
\fBnpm update\fP will install \fBdep1@0\.2\.0\fP, because there are no other
versions which satisfy \fB^0\.2\.0\fP\|\.
.P
If the dependence were on \fB^0\.4\.0\fP:
.P
.RS 2
.nf
"dependencies": {
"dep1": "^0\.4\.0"
}
.fi
.RE
.P
Then \fBnpm update\fP will install \fBdep1@0\.4\.1\fP, because that is the highest\-sorting
version that satisfies \fB^0\.4\.0\fP (\fB>= 0\.4\.0 <0\.5\.0\fP)
.SS Updating Globally\-Installed Packages
.P
\fBnpm update \-g\fP will apply the \fBupdate\fP action to each globally installed
package that is \fBoutdated\fP \-\- that is, has a version that is different from
\fBwanted\fP\|\.
.P
Note: Globally installed packages are treated as if they are installed with a caret semver range specified\. So if you require to update to \fBlatest\fP you may need to run \fBnpm install \-g [<pkg>\.\.\.]\fP
.P
NOTE: If a package has been upgraded to a version newer than \fBlatest\fP, it will
be \fIdowngraded\fR\|\.
.SS See Also
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help outdated
.IP \(bu 2
npm help shrinkwrap
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help ls
.RE

View File

@ -0,0 +1,161 @@
.TH "NPM\-VERSION" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-version\fR \- Bump a package version
.SS Synopsis
.P
.RS 2
.nf
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [\-\-preid=<prerelease\-id>] | from\-git]
\|'npm [\-v | \-\-version]' to print npm version
\|'npm view <pkg> version' to view a package's published version
\|'npm ls' to inspect current package/dependency versions
.fi
.RE
.SS Description
.P
Run this in a package directory to bump the version and write the new
data back to \fBpackage\.json\fP, \fBpackage\-lock\.json\fP, and, if present, \fBnpm\-shrinkwrap\.json\fP\|\.
.P
The \fBnewversion\fP argument should be a valid semver string, a
valid second argument to semver\.inc \fIhttps://github\.com/npm/node\-semver#functions\fR (one of \fBpatch\fP, \fBminor\fP, \fBmajor\fP,
\fBprepatch\fP, \fBpreminor\fP, \fBpremajor\fP, \fBprerelease\fP), or \fBfrom\-git\fP\|\. In the second case,
the existing version will be incremented by 1 in the specified field\.
\fBfrom\-git\fP will try to read the latest git tag, and use that as the new npm version\.
.P
If run in a git repo, it will also create a version commit and tag\.
This behavior is controlled by \fBgit\-tag\-version\fP (see below), and can
be disabled on the command line by running \fBnpm \-\-no\-git\-tag\-version version\fP\|\.
It will fail if the working directory is not clean, unless the \fB\-f\fP or
\fB\-\-force\fP flag is set\.
.P
If supplied with \fB\-m\fP or \fB\-\-message\fP config option, npm will
use it as a commit message when creating a version commit\. If the
\fBmessage\fP config contains \fB%s\fP then that will be replaced with the
resulting version number\. For example:
.P
.RS 2
.nf
npm version patch \-m "Upgrade to %s for reasons"
.fi
.RE
.P
If the \fBsign\-git\-tag\fP config is set, then the tag will be signed using
the \fB\-s\fP flag to git\. Note that you must have a default GPG key set up
in your git config for this to work properly\. For example:
.P
.RS 2
.nf
$ npm config set sign\-git\-tag true
$ npm version patch
You need a passphrase to unlock the secret key for
user: "isaacs (http://blog\.izs\.me/) <i@izs\.me>"
2048\-bit RSA key, ID 6C481CF6, created 2010\-08\-31
Enter passphrase:
.fi
.RE
.P
If \fBpreversion\fP, \fBversion\fP, or \fBpostversion\fP are in the \fBscripts\fP property of
the package\.json, they will be executed as part of running \fBnpm version\fP\|\.
.P
The exact order of execution is as follows:
.RS 0
.IP 1. 3
Check to make sure the git working directory is clean before we get started\.
Your scripts may add files to the commit in future steps\.
This step is skipped if the \fB\-\-force\fP flag is set\.
.IP 2. 3
Run the \fBpreversion\fP script\. These scripts have access to the old \fBversion\fP in package\.json\.
A typical use would be running your full test suite before deploying\.
Any files you want added to the commit should be explicitly added using \fBgit add\fP\|\.
.IP 3. 3
Bump \fBversion\fP in \fBpackage\.json\fP as requested (\fBpatch\fP, \fBminor\fP, \fBmajor\fP, etc)\.
.IP 4. 3
Run the \fBversion\fP script\. These scripts have access to the new \fBversion\fP in package\.json
(so they can incorporate it into file headers in generated files for example)\.
Again, scripts should explicitly add generated files to the commit using \fBgit add\fP\|\.
.IP 5. 3
Commit and tag\.
.IP 6. 3
Run the \fBpostversion\fP script\. Use it to clean up the file system or automatically push
the commit and/or tag\.
.RE
.P
Take the following example:
.P
.RS 2
.nf
"scripts": {
"preversion": "npm test",
"version": "npm run build && git add \-A dist",
"postversion": "git push && git push \-\-tags && rm \-rf build/temp"
}
.fi
.RE
.P
This runs all your tests, and proceeds only if they pass\. Then runs your \fBbuild\fP script, and
adds everything in the \fBdist\fP directory to the commit\. After the commit, it pushes the new commit
and tag up to the server, and deletes the \fBbuild/temp\fP directory\.
.SS Configuration
.SS allow\-same\-version
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Prevents throwing an error when \fBnpm version\fP is used to set the new version
to the same value as the current version\.
.SS git\-tag\-version
.RS 0
.IP \(bu 2
Default: true
.IP \(bu 2
Type: Boolean
.RE
.P
Commit and tag the version change\.
.SS commit\-hooks
.RS 0
.IP \(bu 2
Default: true
.IP \(bu 2
Type: Boolean
.RE
.P
Run git commit hooks when committing the version change\.
.SS sign\-git\-tag
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Pass the \fB\-s\fP flag to git to sign the tag\.
.P
Note that you must have a default GPG key set up in your git config for this to work properly\.
.SS See Also
.RS 0
.IP \(bu 2
npm help init
.IP \(bu 2
npm help run\-script
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help semver
.IP \(bu 2
npm help config
.RE

View File

@ -0,0 +1,143 @@
.TH "NPM\-VIEW" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-view\fR \- View registry info
.SS Synopsis
.P
.RS 2
.nf
npm view [<@scope>/]<name>[@<version>] [<field>[\.<subfield>]\.\.\.]
aliases: info, show, v
.fi
.RE
.SS Description
.P
This command shows data about a package and prints it to the stream
referenced by the \fBoutfd\fP config, which defaults to stdout\.
.P
To show the package registry entry for the \fBconnect\fP package, you can do
this:
.P
.RS 2
.nf
npm view connect
.fi
.RE
.P
The default version is "latest" if unspecified\.
.P
Field names can be specified after the package descriptor\.
For example, to show the dependencies of the \fBronn\fP package at version
0\.3\.5, you could do the following:
.P
.RS 2
.nf
npm view ronn@0\.3\.5 dependencies
.fi
.RE
.P
You can view child fields by separating them with a period\.
To view the git repository URL for the latest version of npm, you could
do this:
.P
.RS 2
.nf
npm view npm repository\.url
.fi
.RE
.P
This makes it easy to view information about a dependency with a bit of
shell scripting\. For example, to view all the data about the version of
opts that ronn depends on, you can do this:
.P
.RS 2
.nf
npm view opts@$(npm view ronn dependencies\.opts)
.fi
.RE
.P
For fields that are arrays, requesting a non\-numeric field will return
all of the values from the objects in the list\. For example, to get all
the contributor names for the "express" project, you can do this:
.P
.RS 2
.nf
npm view express contributors\.email
.fi
.RE
.P
You may also use numeric indices in square braces to specifically select
an item in an array field\. To just get the email address of the first
contributor in the list, you can do this:
.P
.RS 2
.nf
npm view express contributors[0]\.email
.fi
.RE
.P
Multiple fields may be specified, and will be printed one after another\.
For example, to get all the contributor names and email addresses, you
can do this:
.P
.RS 2
.nf
npm view express contributors\.name contributors\.email
.fi
.RE
.P
"Person" fields are shown as a string if they would be shown as an
object\. So, for example, this will show the list of npm contributors in
the shortened string format\. (See npm help \fBpackage\.json\fP for more on this\.)
.P
.RS 2
.nf
npm view npm contributors
.fi
.RE
.P
If a version range is provided, then data will be printed for every
matching version of the package\. This will show which version of jsdom
was required by each matching version of yui3:
.P
.RS 2
.nf
npm view yui3@'>0\.5\.4' dependencies\.jsdom
.fi
.RE
.P
To show the \fBconnect\fP package version history, you can do
this:
.P
.RS 2
.nf
npm view connect versions
.fi
.RE
.SS Output
.P
If only a single string field for a single version is output, then it
will not be colorized or quoted, so as to enable piping the output to
another command\. If the field is an object, it will be output as a JavaScript object literal\.
.P
If the \-\-json flag is given, the outputted fields will be JSON\.
.P
If the version range matches multiple versions, than each printed value
will be prefixed with the version it applies to\.
.P
If multiple fields are requested, than each of them are prefixed with
the field name\.
.SS See Also
.RS 0
.IP \(bu 2
npm help search
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help docs
.RE

View File

@ -0,0 +1,23 @@
.TH "NPM\-WHOAMI" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm-whoami\fR \- Display npm username
.SS Synopsis
.P
.RS 2
.nf
npm whoami [\-\-registry <registry>]
.fi
.RE
.SS Description
.P
Print the \fBusername\fP config to standard output\.
.SS See Also
.RS 0
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help adduser
.RE

View File

@ -0,0 +1,184 @@
.TH "NPM" "1" "August 2021" "" ""
.SH "NAME"
\fBnpm\fR \- javascript package manager
.SS Synopsis
.P
.RS 2
.nf
npm <command> [args]
.fi
.RE
.SS Version
.P
6\.14\.15
.SS Description
.P
npm is the package manager for the Node JavaScript platform\. It puts
modules in place so that node can find them, and manages dependency
conflicts intelligently\.
.P
It is extremely configurable to support a wide variety of use cases\.
Most commonly, it is used to publish, discover, install, and develop node
programs\.
.P
Run \fBnpm help\fP to get a list of available commands\.
.SS Important
.P
npm is configured to use npm, Inc\.'s public registry at
https://registry\.npmjs\.org by default\. Use of the npm public registry is
subject to terms of use available at https://www\.npmjs\.com/policies/terms\.
.P
You can configure npm to use any compatible registry you like, and even run
your own registry\. Use of someone else's registry may be governed by their
terms of use\.
.SS Introduction
.P
You probably got npm because you want to install stuff\.
.P
Use \fBnpm install blerg\fP to install the latest version of "blerg"\. Check out
npm help \fBinstall\fP for more info\. It can do a lot of stuff\.
.P
Use the \fBnpm search\fP command to show everything that's available\.
Use \fBnpm ls\fP to show everything you've installed\.
.SS Dependencies
.P
If a package references to another package with a git URL, npm depends
on a preinstalled git\.
.P
If one of the packages npm tries to install is a native node module and
requires compiling of C++ Code, npm will use
node\-gyp \fIhttps://github\.com/nodejs/node\-gyp\fR for that task\.
For a Unix system, node\-gyp \fIhttps://github\.com/nodejs/node\-gyp\fR
needs Python, make and a buildchain like GCC\. On Windows,
Python and Microsoft Visual Studio C++ are needed\.
For more information visit
the node\-gyp repository \fIhttps://github\.com/nodejs/node\-gyp\fR and
the node\-gyp Wiki \fIhttps://github\.com/nodejs/node\-gyp/wiki\fR\|\.
.SS Directories
.P
See npm help \fBfolders\fP to learn about where npm puts stuff\.
.P
In particular, npm has two modes of operation:
.RS 0
.IP \(bu 2
global mode:
npm installs packages into the install prefix at
\fBprefix/lib/node_modules\fP and bins are installed in \fBprefix/bin\fP\|\.
.IP \(bu 2
local mode:
npm installs packages into the current project directory, which
defaults to the current working directory\. Packages are installed to
\fB\|\./node_modules\fP, and bins are installed to \fB\|\./node_modules/\.bin\fP\|\.
.RE
.P
Local mode is the default\. Use \fB\-g\fP or \fB\-\-global\fP on any command to
operate in global mode instead\.
.SS Developer Usage
.P
If you're using npm to develop and publish your code, check out the
following help topics:
.RS 0
.IP \(bu 2
json:
Make a package\.json file\. See npm help \fBpackage\.json\fP\|\.
.IP \(bu 2
link:
For linking your current working code into Node's path, so that you
don't have to reinstall every time you make a change\. Use
\fBnpm link\fP to do this\.
.IP \(bu 2
install:
It's a good idea to install things if you don't need the symbolic link\.
Especially, installing other peoples code from the registry is done via
\fBnpm install\fP
.IP \(bu 2
adduser:
Create an account or log in\. Credentials are stored in the
user config file\.
.IP \(bu 2
publish:
Use the \fBnpm publish\fP command to upload your code to the registry\.
.RE
.SS Configuration
.P
npm is extremely configurable\. It reads its configuration options from
5 places\.
.RS 0
.IP \(bu 2
Command line switches:
Set a config with \fB\-\-key val\fP\|\. All keys take a value, even if they
are booleans (the config parser doesn't know what the options are at
the time of parsing)\. If no value is provided, then the option is set
to boolean \fBtrue\fP\|\.
.IP \(bu 2
Environment Variables:
Set any config by prefixing the name in an environment variable with
\fBnpm_config_\fP\|\. For example, \fBexport npm_config_key=val\fP\|\.
.IP \(bu 2
User Configs:
The file at $HOME/\.npmrc is an ini\-formatted list of configs\. If
present, it is parsed\. If the \fBuserconfig\fP option is set in the cli
or env, then that will be used instead\.
.IP \(bu 2
Global Configs:
The file found at \.\./etc/npmrc (from the node executable, by default
this resolves to /usr/local/etc/npmrc) will be parsed if it is found\.
If the \fBglobalconfig\fP option is set in the cli, env, or user config,
then that file is parsed instead\.
.IP \(bu 2
Defaults:
npm's default configuration options are defined in
lib/utils/config\-defs\.js\. These must not be changed\.
.RE
.P
See npm help \fBconfig\fP for much much more information\.
.SS Contributions
.P
Patches welcome!
.P
If you would like to contribute, but don't know what to work on, read
the contributing guidelines and check the issues list\.
.RS 0
.IP \(bu 2
CONTRIBUTING\.md \fIhttps://github\.com/npm/cli/blob/latest/CONTRIBUTING\.md\fR
.IP \(bu 2
Bug tracker \fIhttps://github\.com/npm/cli/issues\fR
.RE
.SS Bugs
.P
When you find issues, please report them:
.RS 0
.IP \(bu 2
web:
https://npm\.community/c/bugs
.RE
.P
Be sure to follow the template and bug reporting guidelines\. You can also ask
for help in the support forum \fIhttps://npm\.community/c/support\fR if you're
unsure if it's actually a bug or are having trouble coming up with a detailed
reproduction to report\.
.SS Author
.P
Isaac Z\. Schlueter \fIhttp://blog\.izs\.me/\fR ::
isaacs \fIhttps://github\.com/isaacs/\fR ::
@izs \fIhttps://twitter\.com/izs\fR ::
i@izs\.me
.SS See Also
.RS 0
.IP \(bu 2
npm help help
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help install
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.RE

View File

@ -0,0 +1,175 @@
.TH "NPX" "1" "July 2020" "npx@10.2.3" "User Commands"
.SH "NAME"
\fBnpx\fR \- execute npm package binaries
.SH SYNOPSIS
.P
\fBnpx [options] <command>[@version] [command\-arg]\.\.\.\fP
.P
\fBnpx [options] [\-p|\-\-package <pkg>]\.\.\. <command> [command\-arg]\.\.\.\fP
.P
\fBnpx [options] \-c '<command\-string>'\fP
.P
\fBnpx \-\-shell\-auto\-fallback [shell]\fP
.SH INSTALL
.P
\fBnpm install \-g npx\fP
.SH DESCRIPTION
.P
Executes \fB<command>\fP either from a local \fBnode_modules/\.bin\fP, or from a central cache, installing any packages needed in order for \fB<command>\fP to run\.
.P
By default, \fBnpx\fP will check whether \fB<command>\fP exists in \fB$PATH\fP, or in the local project binaries, and execute that\. If \fB<command>\fP is not found, it will be installed prior to execution\.
.P
Unless a \fB\-\-package\fP option is specified, \fBnpx\fP will try to guess the name of the binary to invoke depending on the specifier provided\. All package specifiers understood by \fBnpm\fP may be used with \fBnpx\fP, including git specifiers, remote tarballs, local directories, or scoped packages\.
.P
If a full specifier is included, or if \fB\-\-package\fP is used, npx will always use a freshly\-installed, temporary version of the package\. This can also be forced with the \fB\-\-ignore\-existing\fP flag\.
.RS 0
.IP \(bu 2
\fB\-p, \-\-package <package>\fP \- define the package to be installed\. This defaults to the value of \fB<command>\fP\|\. This is only needed for packages with multiple binaries if you want to call one of the other executables, or where the binary name does not match the package name\. If this option is provided \fB<command>\fP will be executed as\-is, without interpreting \fB@version\fP if it's there\. Multiple \fB\-\-package\fP options may be provided, and all the packages specified will be installed\.
.IP \(bu 2
\fB\-\-no\-install\fP \- If passed to \fBnpx\fP, it will only try to run \fB<command>\fP if it already exists in the current path or in \fB$prefix/node_modules/\.bin\fP\|\. It won't try to install missing commands\.
.IP \(bu 2
\fB\-\-cache <path>\fP \- set the location of the npm cache\. Defaults to npm's own cache settings\.
.IP \(bu 2
\fB\-\-userconfig <path>\fP \- path to the user configuration file to pass to npm\. Defaults to whatever npm's current default is\.
.IP \(bu 2
\fB\-c <string>\fP \- Execute \fB<string>\fP inside an \fBnpm run\-script\fP\-like shell environment, with all the usual environment variables available\. Only the first item in \fB<string>\fP will be automatically used as \fB<command>\fP\|\. Any others \fImust\fR use \fB\-p\fP\|\.
.IP \(bu 2
\fB\-\-shell <string>\fP \- The shell to invoke the command with, if any\.
.IP \(bu 2
\fB\-\-shell\-auto\-fallback [<shell>]\fP \- Generates shell code to override your shell's "command not found" handler with one that calls \fBnpx\fP\|\. Tries to figure out your shell, or you can pass its name (either \fBbash\fP, \fBfish\fP, or \fBzsh\fP) as an option\. See below for how to install\.
.IP \(bu 2
\fB\-\-ignore\-existing\fP \- If this flag is set, npx will not look in \fB$PATH\fP, or in the current package's \fBnode_modules/\.bin\fP for an existing version before deciding whether to install\. Binaries in those paths will still be available for execution, but will be shadowed by any packages requested by this install\.
.IP \(bu 2
\fB\-q, \-\-quiet\fP \- Suppressed any output from npx itself (progress bars, error messages, install reports)\. Subcommand output itself will not be silenced\.
.IP \(bu 2
\fB\-n, \-\-node\-arg\fP \- Extra node argument to supply to node when binary is a node script\. You can supply this option multiple times to add more arguments\.
.IP \(bu 2
\fB\-v, \-\-version\fP \- Show the current npx version\.
.RE
.SH EXAMPLES
.SS Running a project\-local bin
.P
.RS 2
.nf
$ npm i \-D webpack
$ npx webpack \.\.\.
.fi
.RE
.SS One\-off invocation without local installation
.P
.RS 2
.nf
$ npm rm webpack
$ npx webpack \-\- \.\.\.
$ cat package\.json
\|\.\.\.webpack not in "devDependencies"\.\.\.
.fi
.RE
.SS Invoking a command from a github repository
.P
.RS 2
.nf
$ npx github:piuccio/cowsay
\|\.\.\.or\.\.\.
$ npx git+ssh://my\.hosted\.git:cowsay\.git#semver:^1
\|\.\.\.etc\.\.\.
.fi
.RE
.SS Execute a full shell command using one npx call w/ multiple packages
.P
.RS 2
.nf
$ npx \-p lolcatjs \-p cowsay \-c \\
'echo "$npm_package_name@$npm_package_version" | cowsay | lolcatjs'
\|\.\.\.
_____
< your\-cool\-package@1\.2\.3 >
\-\-\-\-\-
\\ ^__^
\\ (oo)\\_______
(__)\\ )\\/\\
||\-\-\-\-w |
|| ||
.fi
.RE
.SS Run node binary with \-\-inspect
.P
.RS 2
.nf
$ npx \-\-node\-arg=\-\-inspect cowsay
Debugger listening on ws://127\.0\.0\.1:9229/\.\.\.\.
.fi
.RE
.SS Specify a node version to run npm scripts (or anything else!)
.P
.RS 2
.nf
npx \-p node@8 npm run build
.fi
.RE
.SH SHELL AUTO FALLBACK
.P
You can configure \fBnpx\fP to run as your default fallback command when you type something in the command line with an \fB@\fP but the command is not found\. This includes installing packages that were not found in the local prefix either\.
.P
For example:
.P
.RS 2
.nf
$ npm@4 \-\-version
(stderr) npm@4 not found\. Trying with npx\.\.\.
4\.6\.1
$ asdfasdfasf
zsh: command not found: asfdasdfasdf
.fi
.RE
.P
Currently, \fBzsh\fP, \fBbash\fP (>= 4), and \fBfish\fP are supported\. You can access these completion scripts using \fBnpx \-\-shell\-auto\-fallback <shell>\fP\|\.
.P
To install permanently, add the relevant line below to your \fB~/\.bashrc\fP, \fB~/\.zshrc\fP, \fB~/\.config/fish/config\.fish\fP, or as needed\. To install just for the shell session, simply run the line\.
.P
You can optionally pass through \fB\-\-no\-install\fP when generating the fallback to prevent it from installing packages if the command is missing\.
.SS For bash@>=4:
.P
.RS 2
.nf
$ source <(npx \-\-shell\-auto\-fallback bash)
.fi
.RE
.SS For zsh:
.P
.RS 2
.nf
$ source <(npx \-\-shell\-auto\-fallback zsh)
.fi
.RE
.SS For fish:
.P
.RS 2
.nf
$ source (npx \-\-shell\-auto\-fallback fish | psub)
.fi
.RE
.SH ACKNOWLEDGEMENTS
.P
Huge thanks to Kwyn Meagher \fIhttps://blog\.kwyn\.io\fR for generously donating the package name in the main npm registry\. Previously \fBnpx\fP was used for a Tessel board Neopixels library, which can now be found under \fBnpx\-tessel\fP \fIhttps://npm\.im/npx\-tessel\fR\|\.
.SH AUTHOR
.P
Written by Kat Marchan \fIhttps://github\.com/zkat\fR\|\.
.SH REPORTING BUGS
.P
Please file any relevant issues on Github\. \fIhttps://github\.com/npm/npx\fR
.SH LICENSE
.P
This work is released by its authors into the public domain under CC0\-1\.0\. See \fBLICENSE\.md\fP for details\.
.SH SEE ALSO
.RS 0
.IP \(bu 2
\fBnpm(1)\fP
.IP \(bu 2
\fBnpm\-run\-script(1)\fP
.IP \(bu 2
\fBnpm\-config(7)\fP
.RE

View File

@ -0,0 +1,224 @@
.TH "FOLDERS" "5" "August 2021" "" ""
.SH "NAME"
\fBfolders\fR \- Folder Structures Used by npm
.SS Description
.P
npm puts various things on your computer\. That's its job\.
.P
This document will tell you what it puts where\.
.SS tl;dr
.RS 0
.IP \(bu 2
Local install (default): puts stuff in \fB\|\./node_modules\fP of the current
package root\.
.IP \(bu 2
Global install (with \fB\-g\fP): puts stuff in /usr/local or wherever node
is installed\.
.IP \(bu 2
Install it \fBlocally\fR if you're going to \fBrequire()\fP it\.
.IP \(bu 2
Install it \fBglobally\fR if you're going to run it on the command line\.
.IP \(bu 2
If you need both, then install it in both places, or use \fBnpm link\fP\|\.
.RE
.SS prefix Configuration
.P
The \fBprefix\fP config defaults to the location where node is installed\.
On most systems, this is \fB/usr/local\fP\|\. On Windows, it's \fB%AppData%\\npm\fP\|\.
On Unix systems, it's one level up, since node is typically installed at
\fB{prefix}/bin/node\fP rather than \fB{prefix}/node\.exe\fP\|\.
.P
When the \fBglobal\fP flag is set, npm installs things into this prefix\.
When it is not set, it uses the root of the current package, or the
current working directory if not in a package already\.
.SS Node Modules
.P
Packages are dropped into the \fBnode_modules\fP folder under the \fBprefix\fP\|\.
When installing locally, this means that you can
\fBrequire("packagename")\fP to load its main module, or
\fBrequire("packagename/lib/path/to/sub/module")\fP to load other modules\.
.P
Global installs on Unix systems go to \fB{prefix}/lib/node_modules\fP\|\.
Global installs on Windows go to \fB{prefix}/node_modules\fP (that is, no
\fBlib\fP folder\.)
.P
Scoped packages are installed the same way, except they are grouped together
in a sub\-folder of the relevant \fBnode_modules\fP folder with the name of that
scope prefix by the @ symbol, e\.g\. \fBnpm install @myorg/package\fP would place
the package in \fB{prefix}/node_modules/@myorg/package\fP\|\. See npm help \fBscope\fP for more details\.
.P
If you wish to \fBrequire()\fP a package, then install it locally\.
.SS Executables
.P
When in global mode, executables are linked into \fB{prefix}/bin\fP on Unix,
or directly into \fB{prefix}\fP on Windows\.
.P
When in local mode, executables are linked into
\fB\|\./node_modules/\.bin\fP so that they can be made available to scripts run
through npm\. (For example, so that a test runner will be in the path
when you run \fBnpm test\fP\|\.)
.SS Man Pages
.P
When in global mode, man pages are linked into \fB{prefix}/share/man\fP\|\.
.P
When in local mode, man pages are not installed\.
.P
Man pages are not installed on Windows systems\.
.SS Cache
.P
See npm help \fBcache\fP\|\. Cache files are stored in \fB~/\.npm\fP on Posix, or
\fB%AppData%/npm\-cache\fP on Windows\.
.P
This is controlled by the \fBcache\fP configuration param\.
.SS Temp Files
.P
Temporary files are stored by default in the folder specified by the
\fBtmp\fP config, which defaults to the TMPDIR, TMP, or TEMP environment
variables, or \fB/tmp\fP on Unix and \fBc:\\windows\\temp\fP on Windows\.
.P
Temp files are given a unique folder under this root for each run of the
program, and are deleted upon successful exit\.
.SS More Information
.P
When installing locally, npm first tries to find an appropriate
\fBprefix\fP folder\. This is so that \fBnpm install foo@1\.2\.3\fP will install
to the sensible root of your package, even if you happen to have \fBcd\fPed
into some other folder\.
.P
Starting at the $PWD, npm will walk up the folder tree checking for a
folder that contains either a \fBpackage\.json\fP file, or a \fBnode_modules\fP
folder\. If such a thing is found, then that is treated as the effective
"current directory" for the purpose of running npm commands\. (This
behavior is inspired by and similar to git's \.git\-folder seeking
logic when running git commands in a working dir\.)
.P
If no package root is found, then the current folder is used\.
.P
When you run \fBnpm install foo@1\.2\.3\fP, then the package is loaded into
the cache, and then unpacked into \fB\|\./node_modules/foo\fP\|\. Then, any of
foo's dependencies are similarly unpacked into
\fB\|\./node_modules/foo/node_modules/\.\.\.\fP\|\.
.P
Any bin files are symlinked to \fB\|\./node_modules/\.bin/\fP, so that they may
be found by npm scripts when necessary\.
.SS Global Installation
.P
If the \fBglobal\fP configuration is set to true, then npm will
install packages "globally"\.
.P
For global installation, packages are installed roughly the same way,
but using the folders described above\.
.SS Cycles, Conflicts, and Folder Parsimony
.P
Cycles are handled using the property of node's module system that it
walks up the directories looking for \fBnode_modules\fP folders\. So, at every
stage, if a package is already installed in an ancestor \fBnode_modules\fP
folder, then it is not installed at the current location\.
.P
Consider the case above, where \fBfoo \-> bar \-> baz\fP\|\. Imagine if, in
addition to that, baz depended on bar, so you'd have:
\fBfoo \-> bar \-> baz \-> bar \-> baz \.\.\.\fP\|\. However, since the folder
structure is: \fBfoo/node_modules/bar/node_modules/baz\fP, there's no need to
put another copy of bar into \fB\|\.\.\./baz/node_modules\fP, since when it calls
require("bar"), it will get the copy that is installed in
\fBfoo/node_modules/bar\fP\|\.
.P
This shortcut is only used if the exact same
version would be installed in multiple nested \fBnode_modules\fP folders\. It
is still possible to have \fBa/node_modules/b/node_modules/a\fP if the two
"a" packages are different versions\. However, without repeating the
exact same package multiple times, an infinite regress will always be
prevented\.
.P
Another optimization can be made by installing dependencies at the
highest level possible, below the localized "target" folder\.
.SS Example
.P
Consider this dependency graph:
.P
.RS 2
.nf
foo
+\-\- blerg@1\.2\.5
+\-\- bar@1\.2\.3
| +\-\- blerg@1\.x (latest=1\.3\.7)
| +\-\- baz@2\.x
| | `\-\- quux@3\.x
| | `\-\- bar@1\.2\.3 (cycle)
| `\-\- asdf@*
`\-\- baz@1\.2\.3
`\-\- quux@3\.x
`\-\- bar
.fi
.RE
.P
In this case, we might expect a folder structure like this:
.P
.RS 2
.nf
foo
+\-\- node_modules
+\-\- blerg (1\.2\.5) <\-\-\-[A]
+\-\- bar (1\.2\.3) <\-\-\-[B]
| `\-\- node_modules
| +\-\- baz (2\.0\.2) <\-\-\-[C]
| | `\-\- node_modules
| | `\-\- quux (3\.2\.0)
| `\-\- asdf (2\.3\.4)
`\-\- baz (1\.2\.3) <\-\-\-[D]
`\-\- node_modules
`\-\- quux (3\.2\.0) <\-\-\-[E]
.fi
.RE
.P
Since foo depends directly on \fBbar@1\.2\.3\fP and \fBbaz@1\.2\.3\fP, those are
installed in foo's \fBnode_modules\fP folder\.
.P
Even though the latest copy of blerg is 1\.3\.7, foo has a specific
dependency on version 1\.2\.5\. So, that gets installed at [A]\. Since the
parent installation of blerg satisfies bar's dependency on \fBblerg@1\.x\fP,
it does not install another copy under [B]\.
.P
Bar [B] also has dependencies on baz and asdf, so those are installed in
bar's \fBnode_modules\fP folder\. Because it depends on \fBbaz@2\.x\fP, it cannot
re\-use the \fBbaz@1\.2\.3\fP installed in the parent \fBnode_modules\fP folder [D],
and must install its own copy [C]\.
.P
Underneath bar, the \fBbaz \-> quux \-> bar\fP dependency creates a cycle\.
However, because bar is already in quux's ancestry [B], it does not
unpack another copy of bar into that folder\.
.P
Underneath \fBfoo \-> baz\fP [D], quux's [E] folder tree is empty, because its
dependency on bar is satisfied by the parent folder copy installed at [B]\.
.P
For a graphical breakdown of what is installed where, use \fBnpm ls\fP\|\.
.SS Publishing
.P
Upon publishing, npm will look in the \fBnode_modules\fP folder\. If any of
the items there are not in the \fBbundledDependencies\fP array, then they will
not be included in the package tarball\.
.P
This allows a package maintainer to install all of their dependencies
(and dev dependencies) locally, but only re\-publish those items that
cannot be found elsewhere\. See npm help \fBpackage\.json\fP for more information\.
.SS See also
.RS 0
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help install
.IP \(bu 2
npm help pack
.IP \(bu 2
npm help cache
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help config
.IP \(bu 2
npm help publish
.RE

View File

@ -0,0 +1,73 @@
.TH "INSTALL" "5" "August 2021" "" ""
.SH "NAME"
\fBinstall\fR \- Download and Install npm
.SS Description
.P
To publish and install packages to and from the public npm registry, you must install Node\.js and the npm command line interface using either a Node version manager or a Node installer\. \fBWe strongly recommend using a Node version manager to install Node\.js and npm\.\fR We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally\.
.SS Overview
.RS 0
.IP \(bu 2
Checking your version of npm and Node\.js \fI#checking\-your\-version\-of\-npm\-and\-node\-js\fR
.IP \(bu 2
Using a Node version manager to install Node\.js and npm \fI#using\-a\-node\-version\-manager\-to\-install\-node\-js\-and\-npm\fR
.IP \(bu 2
Using a Node installer to install Node\.js and npm \fI#using\-a\-node\-installer\-to\-install\-node\-js\-and\-npm\fR
.RE
.SS Checking your version of npm and Node\.js
.P
To see if you already have Node\.js and npm installed and check the installed version, run the following commands:
.P
.RS 2
.nf
node \-v
npm \-v
.fi
.RE
.SS Using a Node version manager to install Node\.js and npm
.P
Node version managers allow you to install and switch between multiple versions of Node\.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions\.
.SS OSX or Linux Node version managers
.RS 0
.IP \(bu 2
nvm \fIhttps://github\.com/creationix/nvm\fR
.IP \(bu 2
n \fIhttps://github\.com/tj/n\fR
.RE
.SS Windows Node version managers
.RS 0
.IP \(bu 2
nodist \fIhttps://github\.com/marcelklehr/nodist\fR
.IP \(bu 2
nvm\-windows \fIhttps://github\.com/coreybutler/nvm\-windows\fR
.RE
.SS Using a Node installer to install Node\.js and npm
.P
If you are unable to use a Node version manager, you can use a Node installer to install both Node\.js and npm on your system\.
.RS 0
.IP \(bu 2
Node\.js installer \fIhttps://nodejs\.org/en/download/\fR
.IP \(bu 2
NodeSource installer \fIhttps://github\.com/nodesource/distributions\fR\|\. If you use Linux, we recommend that you use a NodeSource installer\.
.RE
.SS OS X or Windows Node installers
.P
If you're using OS X or Windows, use one of the installers from the Node\.js download page \fIhttps://nodejs\.org/en/download/\fR\|\. Be sure to install the version labeled \fBLTS\fR\|\. Other versions have not yet been tested with npm\.
.SS Linux or other operating systems Node installers
.P
If you're using Linux or another operating system, use one of the following installers:
.RS 0
.IP \(bu 2
NodeSource installer \fIhttps://github\.com/nodesource/distributions\fR (recommended)
.IP \(bu 2
One of the installers on the Node\.js download page \fIhttps://nodejs\.org/en/download/\fR
.RE
.P
Or see this page \fIhttps://nodejs\.org/en/download/package\-manager/\fR to install npm for Linux in the way many Linux developers prefer\.
.SS Less\-common operating systems
.P
For more information on installing Node\.js on a variety of operating systems, see this page \fIhttps://nodejs\.org/en/download/package\-manager/\fR\|\.

View File

@ -0,0 +1,108 @@
.TH "NPMRC" "5" "August 2021" "" ""
.SH "NAME"
\fBnpmrc\fR \- The npm config files
.SS Description
.P
npm gets its config settings from the command line, environment
variables, and \fBnpmrc\fP files\.
.P
The \fBnpm config\fP command can be used to update and edit the contents
of the user and global npmrc files\.
.P
For a list of available configuration options, see npm help config\.
.SS Files
.P
The four relevant files are:
.RS 0
.IP \(bu 2
per\-project config file (/path/to/my/project/\.npmrc)
.IP \(bu 2
per\-user config file (~/\.npmrc)
.IP \(bu 2
global config file ($PREFIX/etc/npmrc)
.IP \(bu 2
npm builtin config file (/path/to/npm/npmrc)
.RE
.P
All npm config files are an ini\-formatted list of \fBkey = value\fP
parameters\. Environment variables can be replaced using
\fB${VARIABLE_NAME}\fP\|\. For example:
.P
.RS 2
.nf
prefix = ${HOME}/\.npm\-packages
.fi
.RE
.P
Each of these files is loaded, and config options are resolved in
priority order\. For example, a setting in the userconfig file would
override the setting in the globalconfig file\.
.P
Array values are specified by adding "[]" after the key name\. For
example:
.P
.RS 2
.nf
key[] = "first value"
key[] = "second value"
.fi
.RE
.SS Comments
.P
Lines in \fB\|\.npmrc\fP files are interpreted as comments when they begin with a \fB;\fP or \fB#\fP character\. \fB\|\.npmrc\fP files are parsed by npm/ini \fIhttps://github\.com/npm/ini\fR, which specifies this comment syntax\.
.P
For example:
.P
.RS 2
.nf
# last modified: 01 Jan 2016
; Set a new registry for a scoped package
@myscope:registry=https://mycustomregistry\.example\.org
.fi
.RE
.SS Per\-project config file
.P
When working locally in a project, a \fB\|\.npmrc\fP file in the root of the
project (ie, a sibling of \fBnode_modules\fP and \fBpackage\.json\fP) will set
config values specific to this project\.
.P
Note that this only applies to the root of the project that you're
running npm in\. It has no effect when your module is published\. For
example, you can't publish a module that forces itself to install
globally, or in a different location\.
.P
Additionally, this file is not read in global mode, such as when running
\fBnpm install \-g\fP\|\.
.SS Per\-user config file
.P
\fB$HOME/\.npmrc\fP (or the \fBuserconfig\fP param, if set in the environment
or on the command line)
.SS Global config file
.P
\fB$PREFIX/etc/npmrc\fP (or the \fBglobalconfig\fP param, if set above):
This file is an ini\-file formatted list of \fBkey = value\fP parameters\.
Environment variables can be replaced as above\.
.SS Built\-in config file
.P
\fBpath/to/npm/itself/npmrc\fP
.P
This is an unchangeable "builtin" configuration file that npm keeps
consistent across updates\. Set fields in here using the \fB\|\./configure\fP
script that comes with npm\. This is primarily for distribution
maintainers to override default configs in a standard and consistent
manner\.
.SS See also
.RS 0
.IP \(bu 2
npm help folders
.IP \(bu 2
npm help config
.IP \(bu 2
npm help config
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help npm
.RE

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
.TH "PACKAGE\-LOCK\.JSON" "5" "August 2021" "" ""
.SH "NAME"
\fBpackage-lock.json\fR \- A manifestation of the manifest
.SS Description
.P
\fBpackage\-lock\.json\fP is automatically generated for any operations where npm
modifies either the \fBnode_modules\fP tree, or \fBpackage\.json\fP\|\. It describes the
exact tree that was generated, such that subsequent installs are able to
generate identical trees, regardless of intermediate dependency updates\.
.P
This file is intended to be committed into source repositories, and serves
various purposes:
.RS 0
.IP \(bu 2
Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies\.
.IP \(bu 2
Provide a facility for users to "time\-travel" to previous states of \fBnode_modules\fP without having to commit the directory itself\.
.IP \(bu 2
To facilitate greater visibility of tree changes through readable source control diffs\.
.IP \(bu 2
And optimize the installation process by allowing npm to skip repeated metadata resolutions for previously\-installed packages\.
.RE
.P
One key detail about \fBpackage\-lock\.json\fP is that it cannot be published, and it
will be ignored if found in any place other than the toplevel package\. It shares
a format with npm help npm\-shrinkwrap\.json, which is essentially the same file, but
allows publication\. This is not recommended unless deploying a CLI tool or
otherwise using the publication process for producing production packages\.
.P
If both \fBpackage\-lock\.json\fP and \fBnpm\-shrinkwrap\.json\fP are present in the root of
a package, \fBpackage\-lock\.json\fP will be completely ignored\.
.SS File Format
.SS name
.P
The name of the package this is a package\-lock for\. This must match what's in
\fBpackage\.json\fP\|\.
.SS version
.P
The version of the package this is a package\-lock for\. This must match what's in
\fBpackage\.json\fP\|\.
.SS lockfileVersion
.P
An integer version, starting at \fB1\fP with the version number of this document
whose semantics were used when generating this \fBpackage\-lock\.json\fP\|\.
.SS packageIntegrity
.P
This is a subresource
integrity \fIhttps://w3c\.github\.io/webappsec/specs/subresourceintegrity/\fR value
created from the \fBpackage\.json\fP\|\. No preprocessing of the \fBpackage\.json\fP should
be done\. Subresource integrity strings can be produced by modules like
\fBssri\fP \fIhttps://www\.npmjs\.com/package/ssri\fR\|\.
.SS preserveSymlinks
.P
Indicates that the install was done with the environment variable
\fBNODE_PRESERVE_SYMLINKS\fP enabled\. The installer should insist that the value of
this property match that environment variable\.
.SS dependencies
.P
A mapping of package name to dependency object\. Dependency objects have the
following properties:
.SS version
.P
This is a specifier that uniquely identifies this package and should be
usable in fetching a new copy of it\.
.RS 0
.IP \(bu 2
bundled dependencies: Regardless of source, this is a version number that is purely for informational purposes\.
.IP \(bu 2
registry sources: This is a version number\. (eg, \fB1\.2\.3\fP)
.IP \(bu 2
git sources: This is a git specifier with resolved committish\. (eg, \fBgit+https://example\.com/foo/bar#115311855adb0789a0466714ed48a1499ffea97e\fP)
.IP \(bu 2
http tarball sources: This is the URL of the tarball\. (eg, \fBhttps://example\.com/example\-1\.3\.0\.tgz\fP)
.IP \(bu 2
local tarball sources: This is the file URL of the tarball\. (eg \fBfile:///opt/storage/example\-1\.3\.0\.tgz\fP)
.IP \(bu 2
local link sources: This is the file URL of the link\. (eg \fBfile:libs/our\-module\fP)
.RE
.SS integrity
.P
This is a Standard Subresource
Integrity \fIhttps://w3c\.github\.io/webappsec/specs/subresourceintegrity/\fR for this
resource\.
.RS 0
.IP \(bu 2
For bundled dependencies this is not included, regardless of source\.
.IP \(bu 2
For registry sources, this is the \fBintegrity\fP that the registry provided, or if one wasn't provided the SHA1 in \fBshasum\fP\|\.
.IP \(bu 2
For git sources this is the specific commit hash we cloned from\.
.IP \(bu 2
For remote tarball sources this is an integrity based on a SHA512 of
the file\.
.IP \(bu 2
For local tarball sources: This is an integrity field based on the SHA512 of the file\.
.RE
.SS resolved
.RS 0
.IP \(bu 2
For bundled dependencies this is not included, regardless of source\.
.IP \(bu 2
For registry sources this is path of the tarball relative to the registry
URL\. If the tarball URL isn't on the same server as the registry URL then
this is a complete URL\.
.RE
.SS bundled
.P
If true, this is the bundled dependency and will be installed by the parent
module\. When installing, this module will be extracted from the parent
module during the extract phase, not installed as a separate dependency\.
.SS dev
.P
If true then this dependency is either a development dependency ONLY of the
top level module or a transitive dependency of one\. This is false for
dependencies that are both a development dependency of the top level and a
transitive dependency of a non\-development dependency of the top level\.
.SS optional
.P
If true then this dependency is either an optional dependency ONLY of the
top level module or a transitive dependency of one\. This is false for
dependencies that are both an optional dependency of the top level and a
transitive dependency of a non\-optional dependency of the top level\.
.P
All optional dependencies should be included even if they're uninstallable
on the current platform\.
.SS requires
.P
This is a mapping of module name to version\. This is a list of everything
this module requires, regardless of where it will be installed\. The version
should match via normal matching rules a dependency either in our
\fBdependencies\fP or in a level higher than us\.
.SS dependencies
.P
The dependencies of this dependency, exactly as at the top level\.
.SS See also
.RS 0
.IP \(bu 2
npm help shrinkwrap
.IP \(bu 2
npm help shrinkwrap\.json
.IP \(bu 2
npm help package\-locks
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help install
.RE

View File

@ -0,0 +1,200 @@
.TH "PACKAGE\-LOCKS" "5" "August 2021" "" ""
.SH "NAME"
\fBpackage-locks\fR \- An explanation of npm lockfiles
.SS Description
.P
Conceptually, the "input" to npm help \fBinstall\fP is a npm help package\.json, while its
"output" is a fully\-formed \fBnode_modules\fP tree: a representation of the
dependencies you declared\. In an ideal world, npm would work like a pure
function: the same \fBpackage\.json\fP should produce the exact same \fBnode_modules\fP
tree, any time\. In some cases, this is indeed true\. But in many others, npm is
unable to do this\. There are multiple reasons for this:
.RS 0
.IP \(bu 2
different versions of npm (or other package managers) may have been used to install a package, each using slightly different installation algorithms\.
.IP \(bu 2
a new version of a direct semver\-range package may have been published since the last time your packages were installed, and thus a newer version will be used\.
.IP \(bu 2
A dependency of one of your dependencies may have published a new version, which will update even if you used pinned dependency specifiers (\fB1\.2\.3\fP instead of \fB^1\.2\.3\fP)
.IP \(bu 2
The registry you installed from is no longer available, or allows mutation of versions (unlike the primary npm registry), and a different version of a package exists under the same version number now\.
.RE
.P
As an example, consider package A:
.P
.RS 2
.nf
{
"name": "A",
"version": "0\.1\.0",
"dependencies": {
"B": "<0\.1\.0"
}
}
.fi
.RE
.P
package B:
.P
.RS 2
.nf
{
"name": "B",
"version": "0\.0\.1",
"dependencies": {
"C": "<0\.1\.0"
}
}
.fi
.RE
.P
and package C:
.P
.RS 2
.nf
{
"name": "C",
"version": "0\.0\.1"
}
.fi
.RE
.P
If these are the only versions of A, B, and C available in the
registry, then a normal \fBnpm install A\fP will install:
.P
.RS 2
.nf
A@0\.1\.0
`\-\- B@0\.0\.1
`\-\- C@0\.0\.1
.fi
.RE
.P
However, if B@0\.0\.2 is published, then a fresh \fBnpm install A\fP will
install:
.P
.RS 2
.nf
A@0\.1\.0
`\-\- B@0\.0\.2
`\-\- C@0\.0\.1
.fi
.RE
.P
assuming the new version did not modify B's dependencies\. Of course,
the new version of B could include a new version of C and any number
of new dependencies\. If such changes are undesirable, the author of A
could specify a dependency on B@0\.0\.1\|\. However, if A's author and B's
author are not the same person, there's no way for A's author to say
that he or she does not want to pull in newly published versions of C
when B hasn't changed at all\.
.P
To prevent this potential issue, npm uses npm help package\-lock\.json or, if present, npm help npm\-shrinkwrap\.json\. These files are called package locks, or lockfiles\.
.P
Whenever you run \fBnpm install\fP, npm generates or updates your package lock,
which will look something like this:
.P
.RS 2
.nf
{
"name": "A",
"version": "0\.1\.0",
\.\.\.metadata fields\.\.\.
"dependencies": {
"B": {
"version": "0\.0\.1",
"resolved": "https://registry\.npmjs\.org/B/\-/B\-0\.0\.1\.tgz",
"integrity": "sha512\-DeAdb33F+"
"dependencies": {
"C": {
"version": "git://github\.com/org/C\.git#5c380ae319fc4efe9e7f2d9c78b0faa588fd99b4"
}
}
}
}
}
.fi
.RE
.P
This file describes an \fIexact\fR, and more importantly \fIreproducible\fR
\fBnode_modules\fP tree\. Once it's present, any future installation will base its
work off this file, instead of recalculating dependency versions off
npm help package\.json\.
.P
The presence of a package lock changes the installation behavior such that:
.RS 0
.IP 1. 3
The module tree described by the package lock is reproduced\. This means
reproducing the structure described in the file, using the specific files
referenced in "resolved" if available, falling back to normal package resolution
using "version" if one isn't\.
.IP 2. 3
The tree is walked and any missing dependencies are installed in the usual
fashion\.
.RE
.P
If \fBpreshrinkwrap\fP, \fBshrinkwrap\fP or \fBpostshrinkwrap\fP are in the \fBscripts\fP
property of the \fBpackage\.json\fP, they will be executed in order\. \fBpreshrinkwrap\fP
and \fBshrinkwrap\fP are executed before the shrinkwrap, \fBpostshrinkwrap\fP is
executed afterwards\. These scripts run for both \fBpackage\-lock\.json\fP and
\fBnpm\-shrinkwrap\.json\fP\|\. For example to run some postprocessing on the generated
file:
.P
.RS 2
.nf
"scripts": {
"postshrinkwrap": "json \-I \-e \\"this\.myMetadata = $MY_APP_METADATA\\""
}
.fi
.RE
.SS Using locked packages
.P
Using a locked package is no different than using any package without a package
lock: any commands that update \fBnode_modules\fP and/or \fBpackage\.json\fP\|'s
dependencies will automatically sync the existing lockfile\. This includes \fBnpm
install\fP, \fBnpm rm\fP, \fBnpm update\fP, etc\. To prevent this update from happening,
you can use the \fB\-\-no\-save\fP option to prevent saving altogether, or
\fB\-\-no\-shrinkwrap\fP to allow \fBpackage\.json\fP to be updated while leaving
\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP intact\.
.P
It is highly recommended you commit the generated package lock to source
control: this will allow anyone else on your team, your deployments, your
CI/continuous integration, and anyone else who runs \fBnpm install\fP in your
package source to get the exact same dependency tree that you were developing
on\. Additionally, the diffs from these changes are human\-readable and will
inform you of any changes npm has made to your \fBnode_modules\fP, so you can notice
if any transitive dependencies were updated, hoisted, etc\.
.SS Resolving lockfile conflicts
.P
Occasionally, two separate npm install will create package locks that cause
merge conflicts in source control systems\. As of \fBnpm@5\.7\.0\fP, these conflicts
can be resolved by manually fixing any \fBpackage\.json\fP conflicts, and then
running \fBnpm install [\-\-package\-lock\-only]\fP again\. npm will automatically
resolve any conflicts for you and write a merged package lock that includes all
the dependencies from both branches in a reasonable tree\. If
\fB\-\-package\-lock\-only\fP is provided, it will do this without also modifying your
local \fBnode_modules/\fP\|\.
.P
To make this process seamless on git, consider installing
\fBnpm\-merge\-driver\fP \fIhttps://npm\.im/npm\-merge\-driver\fR, which will teach git how
to do this itself without any user interaction\. In short: \fB$ npx
npm\-merge\-driver install \-g\fP will let you do this, and even works with
pre\-\fBnpm@5\.7\.0\fP versions of npm 5, albeit a bit more noisily\. Note that if
\fBpackage\.json\fP itself conflicts, you will have to resolve that by hand and run
\fBnpm install\fP manually, even with the merge driver\.
.SS See Also
.RS 0
.IP \(bu 2
https://medium\.com/@sdboyer/so\-you\-want\-to\-write\-a\-package\-manager\-4ae9c17d9527
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help package\-lock\.json
.IP \(bu 2
npm help shrinkwrap\.json
.IP \(bu 2
npm help shrinkwrap
.RE

View File

@ -0,0 +1,32 @@
.TH "NPM\-SHRINKWRAP\.JSON" "5" "August 2021" "" ""
.SH "NAME"
\fBnpm-shrinkwrap.json\fR \- A publishable lockfile
.SS Description
.P
\fBnpm\-shrinkwrap\.json\fP is a file created by npm help \fBshrinkwrap\fP\|\. It is identical to
\fBpackage\-lock\.json\fP, with one major caveat: Unlike \fBpackage\-lock\.json\fP,
\fBnpm\-shrinkwrap\.json\fP may be included when publishing a package\.
.P
The recommended use\-case for \fBnpm\-shrinkwrap\.json\fP is applications deployed
through the publishing process on the registry: for example, daemons and
command\-line tools intended as global installs or \fBdevDependencies\fP\|\. It's
strongly discouraged for library authors to publish this file, since that would
prevent end users from having control over transitive dependency updates\.
.P
Additionally, if both \fBpackage\-lock\.json\fP and \fBnpm\-shrinkwrap\.json\fP are present
in a package root, \fBpackage\-lock\.json\fP will be ignored in favor of this file\.
.P
For full details and description of the \fBnpm\-shrinkwrap\.json\fP file format, refer
to the manual page for npm help package\-lock\.json\.
.SS See also
.RS 0
.IP \(bu 2
npm help shrinkwrap
.IP \(bu 2
npm help package\-lock\.json
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help install
.RE

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,291 @@
.TH "DEVELOPERS" "7" "August 2021" "" ""
.SH "NAME"
\fBdevelopers\fR \- Developer Guide
.SS Description
.P
So, you've decided to use npm to develop (and maybe publish/deploy)
your project\.
.P
Fantastic!
.P
There are a few things that you need to do above the simple steps
that your users will do to install your program\.
.SS About These Documents
.P
These are man pages\. If you install npm, you should be able to
then do \fBman npm\-thing\fP to get the documentation on a particular
topic, or \fBnpm help thing\fP to see the same information\.
.SS What is a package
.P
A package is:
.RS 0
.IP \(bu 2
a) a folder containing a program described by a package\.json file
.IP \(bu 2
b) a gzipped tarball containing (a)
.IP \(bu 2
c) a url that resolves to (b)
.IP \(bu 2
d) a \fB<name>@<version>\fP that is published on the registry with (c)
.IP \(bu 2
e) a \fB<name>@<tag>\fP that points to (d)
.IP \(bu 2
f) a \fB<name>\fP that has a "latest" tag satisfying (e)
.IP \(bu 2
g) a \fBgit\fP url that, when cloned, results in (a)\.
.RE
.P
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)\.
.P
Git urls can be of the form:
.P
.RS 2
.nf
git://github\.com/user/project\.git#commit\-ish
git+ssh://user@hostname:project\.git#commit\-ish
git+http://user@hostname/project/blah\.git#commit\-ish
git+https://user@hostname/project/blah\.git#commit\-ish
.fi
.RE
.P
The \fBcommit\-ish\fP can be any tag, sha, or branch which can be supplied as
an argument to \fBgit checkout\fP\|\. The default is \fBmaster\fP\|\.
.SS The package\.json File
.P
You need to have a \fBpackage\.json\fP file in the root of your project to do
much of anything with npm\. That is basically the whole interface\.
.P
See npm help \fBpackage\.json\fP for details about what goes in that file\. At the very
least, you need:
.RS 0
.IP \(bu 2
name:
This should be a string that identifies your project\. Please do not
use the name to specify that it runs on node, or is in JavaScript\.
You can use the "engines" field to explicitly state the versions of
node (or whatever else) that your program requires, and it's pretty
well assumed that it's JavaScript\.
It does not necessarily need to match your github repository name\.
So, \fBnode\-foo\fP and \fBbar\-js\fP are bad names\. \fBfoo\fP or \fBbar\fP are better\.
.IP \(bu 2
version:
A semver\-compatible version\.
.IP \(bu 2
engines:
Specify the versions of node (or whatever else) that your program
runs on\. The node API changes a lot, and there may be bugs or new
functionality that you depend on\. Be explicit\.
.IP \(bu 2
author:
Take some credit\.
.IP \(bu 2
scripts:
If you have a special compilation or installation script, then you
should put it in the \fBscripts\fP object\. You should definitely have at
least a basic smoke\-test command as the "scripts\.test" field\.
See npm help scripts\.
.IP \(bu 2
main:
If you have a single module that serves as the entry point to your
program (like what the "foo" package gives you at require("foo")),
then you need to specify that in the "main" field\.
.IP \(bu 2
directories:
This is an object mapping names to folders\. The best ones to include are
"lib" and "doc", but if you use "man" to specify a folder full of man pages,
they'll get installed just like these ones\.
.RE
.P
You can use \fBnpm init\fP in the root of your package in order to get you
started with a pretty basic package\.json file\. See npm help \fBinit\fP for
more info\.
.SS Keeping files \fIout\fR of your package
.P
Use a \fB\|\.npmignore\fP file to keep stuff out of your package\. If there's
no \fB\|\.npmignore\fP file, but there \fIis\fR a \fB\|\.gitignore\fP file, then npm will
ignore the stuff matched by the \fB\|\.gitignore\fP file\. If you \fIwant\fR to
include something that is excluded by your \fB\|\.gitignore\fP file, you can
create an empty \fB\|\.npmignore\fP file to override it\. Like \fBgit\fP, \fBnpm\fP looks
for \fB\|\.npmignore\fP and \fB\|\.gitignore\fP files in all subdirectories of your
package, not only the root directory\.
.P
\fB\|\.npmignore\fP files follow the same pattern rules \fIhttps://git\-scm\.com/book/en/v2/Git\-Basics\-Recording\-Changes\-to\-the\-Repository#Ignoring\-Files\fR
as \fB\|\.gitignore\fP files:
.RS 0
.IP \(bu 2
Blank lines or lines starting with \fB#\fP are ignored\.
.IP \(bu 2
Standard glob patterns work\.
.IP \(bu 2
You can end patterns with a forward slash \fB/\fP to specify a directory\.
.IP \(bu 2
You can negate a pattern by starting it with an exclamation point \fB!\fP\|\.
.RE
.P
By default, the following paths and files are ignored, so there's no
need to add them to \fB\|\.npmignore\fP explicitly:
.RS 0
.IP \(bu 2
\fB\|\.*\.swp\fP
.IP \(bu 2
\fB\|\._*\fP
.IP \(bu 2
\fB\|\.DS_Store\fP
.IP \(bu 2
\fB\|\.git\fP
.IP \(bu 2
\fB\|\.hg\fP
.IP \(bu 2
\fB\|\.npmrc\fP
.IP \(bu 2
\fB\|\.lock\-wscript\fP
.IP \(bu 2
\fB\|\.svn\fP
.IP \(bu 2
\fB\|\.wafpickle\-*\fP
.IP \(bu 2
\fBconfig\.gypi\fP
.IP \(bu 2
\fBCVS\fP
.IP \(bu 2
\fBnpm\-debug\.log\fP
.RE
.P
Additionally, everything in \fBnode_modules\fP is ignored, except for
bundled dependencies\. npm automatically handles this for you, so don't
bother adding \fBnode_modules\fP to \fB\|\.npmignore\fP\|\.
.P
The following paths and files are never ignored, so adding them to
\fB\|\.npmignore\fP is pointless:
.RS 0
.IP \(bu 2
\fBpackage\.json\fP
.IP \(bu 2
\fBREADME\fP (and its variants)
.IP \(bu 2
\fBCHANGELOG\fP (and its variants)
.IP \(bu 2
\fBLICENSE\fP / \fBLICENCE\fP
.RE
.P
If, given the structure of your project, you find \fB\|\.npmignore\fP to be a
maintenance headache, you might instead try populating the \fBfiles\fP
property of \fBpackage\.json\fP, which is an array of file or directory names
that should be included in your package\. Sometimes a whitelist is easier
to manage than a blacklist\.
.SS Testing whether your \fB\|\.npmignore\fP or \fBfiles\fP config works
.P
If you want to double check that your package will include only the files
you intend it to when published, you can run the \fBnpm pack\fP command locally
which will generate a tarball in the working directory, the same way it
does for publishing\.
.SS Link Packages
.P
\fBnpm link\fP is designed to install a development package and see the
changes in real time without having to keep re\-installing it\. (You do
need to either re\-link or \fBnpm rebuild \-g\fP to update compiled packages,
of course\.)
.P
More info at npm help \fBlink\fP\|\.
.SS Before Publishing: Make Sure Your Package Installs and Works
.P
\fBThis is important\.\fR
.P
If you can not install it locally, you'll have
problems trying to publish it\. Or, worse yet, you'll be able to
publish it, but you'll be publishing a broken or pointless package\.
So don't do that\.
.P
In the root of your package, do this:
.P
.RS 2
.nf
npm install \. \-g
.fi
.RE
.P
That'll show you that it's working\. If you'd rather just create a symlink
package that points to your working directory, then do this:
.P
.RS 2
.nf
npm link
.fi
.RE
.P
Use \fBnpm ls \-g\fP to see if it's there\.
.P
To test a local install, go into some other folder, and then do:
.P
.RS 2
.nf
cd \.\./some\-other\-folder
npm install \.\./my\-package
.fi
.RE
.P
to install it locally into the node_modules folder in that other place\.
.P
Then go into the node\-repl, and try using require("my\-thing") to
bring in your module's main module\.
.SS Create a User Account
.P
Create a user with the adduser command\. It works like this:
.P
.RS 2
.nf
npm adduser
.fi
.RE
.P
and then follow the prompts\.
.P
This is documented better in npm help adduser\.
.SS Publish your package
.P
This part's easy\. In the root of your folder, do this:
.P
.RS 2
.nf
npm publish
.fi
.RE
.P
You can give publish a url to a tarball, or a filename of a tarball,
or a path to a folder\.
.P
Note that pretty much \fBeverything in that folder will be exposed\fR
by default\. So, if you have secret stuff in there, use a
\fB\|\.npmignore\fP file to list out the globs to ignore, or publish
from a fresh checkout\.
.SS Brag about it
.P
Send emails, write blogs, blab in IRC\.
.P
Tell the world how easy it is to install your program!
.SS See also
.RS 0
.IP \(bu 2
npm help npm
.IP \(bu 2
npm help init
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help scripts
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help adduser
.IP \(bu 2
npm help registry
.RE

View File

@ -0,0 +1,149 @@
.TH "DISPUTES" "7" "August 2021" "" ""
.SH "NAME"
\fBdisputes\fR \- Handling Module Name Disputes
.P
This document describes the steps that you should take to resolve module name
disputes with other npm publishers\. It also describes special steps you should
take about names you think infringe your trademarks\.
.P
This document is a clarification of the acceptable behavior outlined in the
npm Code of Conduct \fIhttps://www\.npmjs\.com/policies/conduct\fR, and nothing in
this document should be interpreted to contradict any aspect of the npm Code of
Conduct\.
.SS TL;DR
.RS 0
.IP 1. 3
Get the author email with \fBnpm owner ls <pkgname>\fP
.IP 2. 3
Email the author, CC support@npmjs\.com
.IP 3. 3
After a few weeks, if there's no resolution, we'll sort it out\.
.RE
.P
Don't squat on package names\. Publish code or move out of the way\.
.SS Description
.P
There sometimes arise cases where a user publishes a module, and then later,
some other user wants to use that name\. Here are some common ways that happens
(each of these is based on actual events\.)
.RS 0
.IP 1. 3
Alice writes a JavaScript module \fBfoo\fP, which is not node\-specific\. Alice
doesn't use node at all\. Yusuf wants to use \fBfoo\fP in node, so he wraps it in
an npm module\. Some time later, Alice starts using node, and wants to take
over management of her program\.
.IP 2. 3
Yusuf writes an npm module \fBfoo\fP, and publishes it\. Perhaps much later, Alice
finds a bug in \fBfoo\fP, and fixes it\. She sends a pull request to Yusuf, but
Yusuf doesn't have the time to deal with it, because he has a new job and a
new baby and is focused on his new Erlang project, and kind of not involved
with node any more\. Alice would like to publish a new \fBfoo\fP, but can't,
because the name is taken\.
.IP 3. 3
Yusuf writes a 10\-line flow\-control library, and calls it \fBfoo\fP, and
publishes it to the npm registry\. Being a simple little thing, it never
really has to be updated\. Alice works for Foo Inc, the makers of the
critically acclaimed and widely\-marketed \fBfoo\fP JavaScript toolkit framework\.
They publish it to npm as \fBfoojs\fP, but people are routinely confused when
\fBnpm install foo\fP is some different thing\.
.IP 4. 3
Yusuf writes a parser for the widely\-known \fBfoo\fP file format, because he
needs it for work\. Then, he gets a new job, and never updates the prototype\.
Later on, Alice writes a much more complete \fBfoo\fP parser, but can't publish,
because Yusuf's \fBfoo\fP is in the way\.
.IP 5. 3
\fBnpm owner ls foo\fP\|\. This will tell Alice the email address of the owner
(Yusuf)\.
.IP 6. 3
Alice emails Yusuf, explaining the situation \fBas respectfully as possible\fR,
and what she would like to do with the module name\. She adds the npm support
staff support@npmjs\.com to the CC list of the email\. Mention in the email
that Yusuf can run npm owner \fBadd alice foo\fP to add Alice as an owner of the
foo package\.
.IP 7. 3
After a reasonable amount of time, if Yusuf has not responded, or if Yusuf
and Alice can't come to any sort of resolution, email support
support@npmjs\.com and we'll sort it out\. ("Reasonable" is usually at least
4 weeks\.)
.RE
.SS Reasoning
.P
In almost every case so far, the parties involved have been able to reach an
amicable resolution without any major intervention\. Most people really do want
to be reasonable, and are probably not even aware that they're in your way\.
.P
Module ecosystems are most vibrant and powerful when they are as self\-directed
as possible\. If an admin one day deletes something you had worked on, then that
is going to make most people quite upset, regardless of the justification\. When
humans solve their problems by talking to other humans with respect, everyone
has the chance to end up feeling good about the interaction\.
.SS Exceptions
.P
Some things are not allowed, and will be removed without discussion if they are
brought to the attention of the npm registry admins, including but not limited
to:
.RS 0
.IP 1. 3
Malware (that is, a package designed to exploit or harm the machine on which
it is installed)\.
.IP 2. 3
Violations of copyright or licenses (for example, cloning an MIT\-licensed
program, and then removing or changing the copyright and license statement)\.
.IP 3. 3
Illegal content\.
.IP 4. 3
"Squatting" on a package name that you plan to use, but aren't actually
using\. Sorry, I don't care how great the name is, or how perfect a fit it is
for the thing that someday might happen\. If someone wants to use it today,
and you're just taking up space with an empty tarball, you're going to be
evicted\.
.IP 5. 3
Putting empty packages in the registry\. Packages must have SOME
functionality\. It can be silly, but it can't be nothing\. (See also:
squatting\.)
.IP 6. 3
Doing weird things with the registry, like using it as your own personal
application database or otherwise putting non\-packagey things into it\.
.IP 7. 3
Other things forbidden by the npm
Code of Conduct \fIhttps://www\.npmjs\.com/policies/conduct\fR such as hateful
language, pornographic content, or harassment\.
.RE
.P
If you see bad behavior like this, please report it to abuse@npmjs\.com right
away\. \fBYou are never expected to resolve abusive behavior on your own\. We are
here to help\.\fR
.SS Trademarks
.P
If you think another npm publisher is infringing your trademark, such as by
using a confusingly similar package name, email abuse@npmjs\.com with a link to
the package or user account on https://www\.npmjs\.com/ \fIhttps://www\.npmjs\.com/\fR\|\.
Attach a copy of your trademark registration certificate\.
.P
If we see that the package's publisher is intentionally misleading others by
misusing your registered mark without permission, we will transfer the package
name to you\. Otherwise, we will contact the package publisher and ask them to
clear up any confusion with changes to their package's \fBREADME\fP file or
metadata\.
.SS Changes
.P
This is a living document and may be updated from time to time\. Please refer to
the git history for this document \fIhttps://github\.com/npm/cli/commits/latest/doc/misc/npm\-disputes\.md\fR
to view the changes\.
.SS License
.P
Copyright (C) npm, Inc\., All rights reserved
.P
This document may be reused under a Creative Commons Attribution\-ShareAlike
License\.
.SS See also
.RS 0
.IP \(bu 2
npm help registry
.IP \(bu 2
npm help owner
.RE

View File

@ -0,0 +1,146 @@
.TH "ORGS" "7" "August 2021" "" ""
.SH "NAME"
\fBorgs\fR \- Working with Teams & Orgs
.SS Description
.P
There are three levels of org users:
.RS 0
.IP 1. 3
Super admin, controls billing & adding people to the org\.
.IP 2. 3
Team admin, manages team membership & package access\.
.IP 3. 3
Developer, works on packages they are given access to\.
.RE
.P
The super admin is the only person who can add users to the org because it impacts the monthly bill\. The super admin will use the website to manage membership\. Every org has a \fBdevelopers\fP team that all users are automatically added to\.
.P
The team admin is the person who manages team creation, team membership, and package access for teams\. The team admin grants package access to teams, not individuals\.
.P
The developer will be able to access packages based on the teams they are on\. Access is either read\-write or read\-only\.
.P
There are two main commands:
.RS 0
.IP 1. 3
\fBnpm team\fP see npm help team for more details
.IP 2. 3
\fBnpm access\fP see npm help access for more details
.RE
.SS Team Admins create teams
.RS 0
.IP \(bu 2
Check who youve added to your org:
.RE
.P
.RS 2
.nf
npm team ls <org>:developers
.fi
.RE
.RS 0
.IP \(bu 2
Each org is automatically given a \fBdevelopers\fP team, so you can see the whole list of team members in your org\. This team automatically gets read\-write access to all packages, but you can change that with the \fBaccess\fP command\.
.IP \(bu 2
Create a new team:
.RE
.P
.RS 2
.nf
npm team create <org:team>
.fi
.RE
.RS 0
.IP \(bu 2
Add members to that team:
.RE
.P
.RS 2
.nf
npm team add <org:team> <user>
.fi
.RE
.SS Publish a package and adjust package access
.RS 0
.IP \(bu 2
In package directory, run
.RE
.P
.RS 2
.nf
npm init \-\-scope=<org>
.fi
.RE
.P
to scope it for your org & publish as usual
.RS 0
.IP \(bu 2
Grant access:
.RE
.P
.RS 2
.nf
npm access grant <read\-only|read\-write> <org:team> [<package>]
.fi
.RE
.RS 0
.IP \(bu 2
Revoke access:
.RE
.P
.RS 2
.nf
npm access revoke <org:team> [<package>]
.fi
.RE
.SS Monitor your package access
.RS 0
.IP \(bu 2
See what org packages a team member can access:
.RE
.P
.RS 2
.nf
npm access ls\-packages <org> <user>
.fi
.RE
.RS 0
.IP \(bu 2
See packages available to a specific team:
.RE
.P
.RS 2
.nf
npm access ls\-packages <org:team>
.fi
.RE
.RS 0
.IP \(bu 2
Check which teams are collaborating on a package:
.RE
.P
.RS 2
.nf
npm access ls\-collaborators <pkg>
.fi
.RE
.SS See also
.RS 0
.IP \(bu 2
npm help team
.IP \(bu 2
npm help access
.IP \(bu 2
npm help scope
.RE

View File

@ -0,0 +1,104 @@
.TH "REGISTRY" "7" "August 2021" "" ""
.SH "NAME"
\fBregistry\fR \- The JavaScript Package Registry
.SS Description
.P
To resolve packages by name and version, npm talks to a registry website
that implements the CommonJS Package Registry specification for reading
package info\.
.P
npm is configured to use npm, Inc\.'s public registry at
https://registry\.npmjs\.org by default\. Use of the npm public registry is
subject to terms of use available at https://www\.npmjs\.com/policies/terms\|\.
.P
You can configure npm to use any compatible registry you like, and even run
your own registry\. Use of someone else's registry may be governed by their
terms of use\.
.P
npm's package registry implementation supports several
write APIs as well, to allow for publishing packages and managing user
account information\.
.P
The npm public registry is powered by a CouchDB database,
of which there is a public mirror at
https://skimdb\.npmjs\.com/registry\|\. The code for the couchapp is
available at https://github\.com/npm/npm\-registry\-couchapp\|\.
.P
The registry URL used is determined by the scope of the package (see
npm help \fBscope\fP\|\. If no scope is specified, the default registry is used, which is
supplied by the \fBregistry\fP config parameter\. See npm help \fBconfig\fP,
npm help \fBnpmrc\fP, and npm help \fBconfig\fP for more on managing npm's configuration\.
.SS Does npm send any information about me back to the registry?
.P
Yes\.
.P
When making requests of the registry npm adds two headers with information
about your environment:
.RS 0
.IP \(bu 2
\fBNpm\-Scope\fP If your project is scoped, this header will contain its
scope\. In the future npm hopes to build registry features that use this
information to allow you to customize your experience for your
organization\.
.IP \(bu 2
\fBNpm\-In\-CI\fP Set to "true" if npm believes this install is running in a
continuous integration environment, "false" otherwise\. This is detected by
looking for the following environment variables: \fBCI\fP, \fBTDDIUM\fP,
\fBJENKINS_URL\fP, \fBbamboo\.buildKey\fP\|\. If you'd like to learn more you may find
the original PR \fIhttps://github\.com/npm/npm\-registry\-client/pull/129\fR
interesting\.
This is used to gather better metrics on how npm is used by humans, versus
build farms\.
.RE
.P
The npm registry does not try to correlate the information in these headers
with any authenticated accounts that may be used in the same requests\.
.SS Can I run my own private registry?
.P
Yes!
.P
The easiest way is to replicate the couch database, and use the same (or
similar) design doc to implement the APIs\.
.P
If you set up continuous replication from the official CouchDB, and then
set your internal CouchDB as the registry config, then you'll be able
to read any published packages, in addition to your private ones, and by
default will only publish internally\.
.P
If you then want to publish a package for the whole world to see, you can
simply override the \fB\-\-registry\fP option for that \fBpublish\fP command\.
.SS I don't want my package published in the official registry\. It's private\.
.P
Set \fB"private": true\fP in your package\.json to prevent it from being
published at all, or
\fB"publishConfig":{"registry":"http://my\-internal\-registry\.local"}\fP
to force it to be published only to your internal registry\.
.P
See npm help \fBpackage\.json\fP for more info on what goes in the package\.json file\.
.SS Will you replicate from my registry into the public one?
.P
No\. If you want things to be public, then publish them into the public
registry using npm\. What little security there is would be for nought
otherwise\.
.SS Do I have to use couchdb to build a registry that npm can talk to?
.P
No, but it's way easier\. Basically, yes, you do, or you have to
effectively implement the entire CouchDB API anyway\.
.SS Is there a website or something to see package docs and such?
.P
Yes, head over to https://www\.npmjs\.com/
.SS See also
.RS 0
.IP \(bu 2
npm help config
.IP \(bu 2
npm help config
.IP \(bu 2
npm help npmrc
.IP \(bu 2
npm help developers
.IP \(bu 2
npm help disputes
.RE

View File

@ -0,0 +1,75 @@
.TH "REMOVAL" "7" "August 2021" "" ""
.SH "NAME"
\fBremoval\fR \- Cleaning the Slate
.SS Synopsis
.P
So sad to see you go\.
.P
.RS 2
.nf
sudo npm uninstall npm \-g
.fi
.RE
.P
Or, if that fails, get the npm source code, and do:
.P
.RS 2
.nf
sudo make uninstall
.fi
.RE
.SS More Severe Uninstalling
.P
Usually, the above instructions are sufficient\. That will remove
npm, but leave behind anything you've installed\.
.P
If that doesn't work, or if you require more drastic measures,
continue reading\.
.P
Note that this is only necessary for globally\-installed packages\. Local
installs are completely contained within a project's \fBnode_modules\fP
folder\. Delete that folder, and everything is gone less a package's
install script is particularly ill\-behaved)\.
.P
This assumes that you installed node and npm in the default place\. If
you configured node with a different \fB\-\-prefix\fP, or installed npm with a
different prefix setting, then adjust the paths accordingly, replacing
\fB/usr/local\fP with your install prefix\.
.P
To remove everything npm\-related manually:
.P
.RS 2
.nf
rm \-rf /usr/local/{lib/node{,/\.npm,_modules},bin,share/man}/npm*
.fi
.RE
.P
If you installed things \fIwith\fR npm, then your best bet is to uninstall
them with npm first, and then install them again once you have a
proper install\. This can help find any symlinks that are lying
around:
.P
.RS 2
.nf
ls \-laF /usr/local/{lib/node{,/\.npm},bin,share/man} | grep npm
.fi
.RE
.P
Prior to version 0\.3, npm used shim files for executables and node
modules\. To track those down, you can do the following:
.P
.RS 2
.nf
find /usr/local/{lib/node,bin} \-exec grep \-l npm \\{\\} \\; ;
.fi
.RE
.P
(This is also in the README file\.)
.SS See also
.RS 0
.IP \(bu 2
npm help uninstall
.IP \(bu 2
npm help prune
.RE

View File

@ -0,0 +1,136 @@
.TH "SCOPE" "7" "August 2021" "" ""
.SH "NAME"
\fBscope\fR \- Scoped packages
.SS Description
.P
All npm packages have a name\. Some package names also have a scope\. A scope
follows the usual rules for package names (URL\-safe characters, no leading dots
or underscores)\. When used in package names, scopes are preceded by an \fB@\fP symbol
and followed by a slash, e\.g\.
.P
.RS 2
.nf
@somescope/somepackagename
.fi
.RE
.P
Scopes are a way of grouping related packages together, and also affect a few
things about the way npm treats the package\.
.P
Each npm user/organization has their own scope, and only you can add packages
in your scope\. This means you don't have to worry about someone taking your
package name ahead of you\. Thus it is also a good way to signal official packages
for organizations\.
.P
Scoped packages can be published and installed as of \fBnpm@2\fP and are supported
by the primary npm registry\. Unscoped packages can depend on scoped packages and
vice versa\. The npm client is backwards\-compatible with unscoped registries,
so it can be used to work with scoped and unscoped registries at the same time\.
.SS Installing scoped packages
.P
Scoped packages are installed to a sub\-folder of the regular installation
folder, e\.g\. if your other packages are installed in \fBnode_modules/packagename\fP,
scoped modules will be installed in \fBnode_modules/@myorg/packagename\fP\|\. The scope
folder (\fB@myorg\fP) is simply the name of the scope preceded by an \fB@\fP symbol, and can
contain any number of scoped packages\.
.P
A scoped package is installed by referencing it by name, preceded by an
\fB@\fP symbol, in \fBnpm install\fP:
.P
.RS 2
.nf
npm install @myorg/mypackage
.fi
.RE
.P
Or in \fBpackage\.json\fP:
.P
.RS 2
.nf
"dependencies": {
"@myorg/mypackage": "^1\.3\.0"
}
.fi
.RE
.P
Note that if the \fB@\fP symbol is omitted, in either case, npm will instead attempt to
install from GitHub; see npm help \fBinstall\fP\|\.
.SS Requiring scoped packages
.P
Because scoped packages are installed into a scope folder, you have to
include the name of the scope when requiring them in your code, e\.g\.
.P
.RS 2
.nf
require('@myorg/mypackage')
.fi
.RE
.P
There is nothing special about the way Node treats scope folders\. This
simply requires the \fBmypackage\fP module in the folder named \fB@myorg\fP\|\.
.SS Publishing scoped packages
.P
Scoped packages can be published from the CLI as of \fBnpm@2\fP and can be
published to any registry that supports them, including the primary npm
registry\.
.P
(As of 2015\-04\-19, and with npm 2\.0 or better, the primary npm registry
\fBdoes\fR support scoped packages\.)
.P
If you wish, you may associate a scope with a registry; see below\.
.SS Publishing public scoped packages to the primary npm registry
.P
To publish a public scoped package, you must specify \fB\-\-access public\fP with
the initial publication\. This will publish the package and set access
to \fBpublic\fP as if you had run \fBnpm access public\fP after publishing\.
.SS Publishing private scoped packages to the npm registry
.P
To publish a private scoped package to the npm registry, you must have
an npm Private Modules \fIhttps://docs\.npmjs\.com/private\-modules/intro\fR
account\.
.P
You can then publish the module with \fBnpm publish\fP or \fBnpm publish
\-\-access restricted\fP, and it will be present in the npm registry, with
restricted access\. You can then change the access permissions, if
desired, with \fBnpm access\fP or on the npmjs\.com website\.
.SS Associating a scope with a registry
.P
Scopes can be associated with a separate registry\. This allows you to
seamlessly use a mix of packages from the primary npm registry and one or more
private registries, such as npm Enterprise\.
.P
You can associate a scope with a registry at login, e\.g\.
.P
.RS 2
.nf
npm login \-\-registry=http://reg\.example\.com \-\-scope=@myco
.fi
.RE
.P
Scopes have a many\-to\-one relationship with registries: one registry can
host multiple scopes, but a scope only ever points to one registry\.
.P
You can also associate a scope with a registry using \fBnpm config\fP:
.P
.RS 2
.nf
npm config set @myco:registry http://reg\.example\.com
.fi
.RE
.P
Once a scope is associated with a registry, any \fBnpm install\fP for a package
with that scope will request packages from that registry instead\. Any
\fBnpm publish\fP for a package name that contains the scope will be published to
that registry instead\.
.SS See also
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help publish
.IP \(bu 2
npm help access
.IP \(bu 2
npm help registry
.RE

View File

@ -0,0 +1,376 @@
.TH "SCRIPTS" "7" "August 2021" "" ""
.SH "NAME"
\fBscripts\fR \- How npm handles the "scripts" field
.SS Description
.P
The \fB"scripts"\fP property of of your \fBpackage\.json\fP file supports a number of built\-in scripts and their preset life cycle events as well as arbitrary scripts\. These all can be executed by running \fBnpm run\-script <stage>\fP or \fBnpm run <stage>\fP for short\. \fIPre\fR and \fIpost\fR commands with matching names will be run for those as well (e\.g\. \fBpremyscript\fP, \fBmyscript\fP, \fBpostmyscript\fP)\. Scripts from dependencies can be run with \fBnpm explore <pkg> \-\- npm run <stage>\fP\|\.
.SS Pre & Post Scripts
.P
To create "pre" or "post" scripts for any scripts defined in the \fB"scripts"\fP section of the \fBpackage\.json\fP, simply create another script \fIwith a matching name\fR and add "pre" or "post" to the beginning of them\.
.P
.RS 2
.nf
{
"scripts": {
"precompress": "{{ executes BEFORE the `compress` script }}",
"compress": "{{ run command to compress files }}",
"postcompress": "{{ executes AFTER `compress` script }}"
}
}
.fi
.RE
.SS Life Cycle Scripts
.P
There are some special life cycle scripts that happen only in certain situations\. These scripts happen in addtion to the "pre" and "post" script\.
.RS 0
.IP \(bu 2
\fBprepare\fP, \fBprepublish\fP, \fBprepublishOnly\fP, \fBprepack\fP, \fBpostpack\fP
.RE
.P
\fBprepare\fR (since \fBnpm@4\.0\.0\fP)
.RS 0
.IP \(bu 2
Runs BEFORE the package is packed
.IP \(bu 2
Runs BEFORE the package is published
.IP \(bu 2
Runs on local \fBnpm install\fP without any arguments
.IP \(bu 2
Run AFTER \fBprepublish\fP, but BEFORE \fBprepublishOnly\fP
.IP \(bu 2
NOTE: If a package being installed through git 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\.
.RE
.P
\fBprepublish\fR (DEPRECATED)
.RS 0
.IP \(bu 2
Same as \fBprepare\fP
.RE
.P
\fBprepublishOnly\fR
.RS 0
.IP \(bu 2
Runs BEFORE the package is prepared and packed, ONLY on \fBnpm publish\fP\|\.
.RE
.P
\fBprepack\fR
.RS 0
.IP \(bu 2
Runs BEFORE a tarball is packed (on "\fBnpm pack\fP", "\fBnpm publish\fP", and when installing a git dependencies)\.
.IP \(bu 2
NOTE: "\fBnpm run pack\fP" is NOT the same as "\fBnpm pack\fP"\. "\fBnpm run pack\fP" is an arbitrary user defined script name, where as, "\fBnpm pack\fP" is a CLI defined command\.
.RE
.P
\fBpostpack\fR
.RS 0
.IP \(bu 2
Runs AFTER the tarball has been generated and moved to its final destination\.
.RE
.SS Prepare and Prepublish
.P
\fBDeprecation Note: prepublish\fR
.P
Since \fBnpm@1\.1\.71\fP, the npm CLI has run the \fBprepublish\fP script for both \fBnpm publish\fP and \fBnpm install\fP, because it's a convenient way to prepare a package for use (some common use cases are described in the section below)\. It has also turned out to be, in practice, very confusing \fIhttps://github\.com/npm/npm/issues/10074\fR\|\. As of \fBnpm@4\.0\.0\fP, a new event has been introduced, \fBprepare\fP, that preserves this existing behavior\. A \fInew\fR event, \fBprepublishOnly\fP has been added as a transitional strategy to allow users to avoid the confusing behavior of existing npm versions and only run on \fBnpm publish\fP (for instance, running the tests one last time to ensure they're in good shape)\.
.P
See https://github\.com/npm/npm/issues/10074 for a much lengthier justification, with further reading, for this change\.
.P
\fBUse Cases\fR
.P
If you need to perform operations on your package before it is used, in a way that is not dependent on the operating system or architecture of the target system, use a \fBprepublish\fP script\. This includes tasks such as:
.RS 0
.IP \(bu 2
Compiling CoffeeScript source code into JavaScript\.
.IP \(bu 2
Creating minified versions of JavaScript source code\.
.IP \(bu 2
Fetching remote resources that your package will use\.
.RE
.P
The advantage of doing these things at \fBprepublish\fP time is that they can be done once, in a single place, thus reducing complexity and variability\. Additionally, this means that:
.RS 0
.IP \(bu 2
You can depend on \fBcoffee\-script\fP as a \fBdevDependency\fP, and thus
your users don't need to have it installed\.
.IP \(bu 2
You don't need to include minifiers in your package, reducing
the size for your users\.
.IP \(bu 2
You don't need to rely on your users having \fBcurl\fP or \fBwget\fP or
other system tools on the target machines\.
.RE
.SS Life Cycle Operation Order
.SS npm help \fBpublish\fP
.RS 0
.IP \(bu 2
\fBprepublishOnly\fP
.IP \(bu 2
\fBprepare\fP
.IP \(bu 2
\fBprepublish\fP
.IP \(bu 2
\fBpublish\fP
.IP \(bu 2
\fBpostpublish\fP
.RE
.SS npm help \fBpack\fP
.RS 0
.IP \(bu 2
\fBprepack\fP
.IP \(bu 2
\fBpostpack\fP
.RE
.SS npm help \fBinstall\fP
.RS 0
.IP \(bu 2
\fBpreinstall\fP
.IP \(bu 2
\fBinstall\fP
.IP \(bu 2
\fBpostinstall\fP
.RE
.P
Also triggers
.RS 0
.IP \(bu 2
\fBprepublish\fP (when on local)
.IP \(bu 2
\fBprepare\fP (when on local)
.RE
.SS npm help \fBstart\fP
.P
\fBnpm run start\fP has an \fBnpm start\fP shorthand\.
.RS 0
.IP \(bu 2
\fBprestart\fP
.IP \(bu 2
\fBstart\fP
.IP \(bu 2
\fBpoststart\fP
.RE
.SS Default Values
.P
npm will default some script values based on package contents\.
.RS 0
.IP \(bu 2
\fB"start": "node server\.js"\fP:
If there is a \fBserver\.js\fP file in the root of your package, then npm
will default the \fBstart\fP command to \fBnode server\.js\fP\|\.
.IP \(bu 2
\fB"install": "node\-gyp rebuild"\fP:
If there is a \fBbinding\.gyp\fP file in the root of your package and you
haven't defined your own \fBinstall\fP or \fBpreinstall\fP scripts, npm will
default the \fBinstall\fP command to compile using node\-gyp\.
.RE
.SS User
.P
If npm was invoked with root privileges, then it will change the uid
to the user account or uid specified by the \fBuser\fP config, which
defaults to \fBnobody\fP\|\. Set the \fBunsafe\-perm\fP flag to run scripts with
root privileges\.
.SS Environment
.P
Package scripts run in an environment where many pieces of information
are made available regarding the setup of npm and the current state of
the process\.
.SS path
.P
If you depend on modules that define executable scripts, like test
suites, then those executables will be added to the \fBPATH\fP for
executing the scripts\. So, if your package\.json has this:
.P
.RS 2
.nf
{
"name" : "foo",
"dependencies" : {
"bar" : "0\.1\.x"
},
"scripts": {
"start" : "bar \./test"
}
}
.fi
.RE
.P
then you could run \fBnpm start\fP to execute the \fBbar\fP script, which is
exported into the \fBnode_modules/\.bin\fP directory on \fBnpm install\fP\|\.
.SS package\.json vars
.P
The package\.json fields are tacked onto the \fBnpm_package_\fP prefix\. So,
for instance, if you had \fB{"name":"foo", "version":"1\.2\.5"}\fP in your
package\.json file, then your package scripts would have the
\fBnpm_package_name\fP environment variable set to "foo", and the
\fBnpm_package_version\fP set to "1\.2\.5"\. You can access these variables
in your code with \fBprocess\.env\.npm_package_name\fP and
\fBprocess\.env\.npm_package_version\fP, and so on for other fields\.
.SS configuration
.P
Configuration parameters are put in the environment with the
\fBnpm_config_\fP prefix\. For instance, you can view the effective \fBroot\fP
config by checking the \fBnpm_config_root\fP environment variable\.
.SS Special: package\.json "config" object
.P
The package\.json "config" keys are overwritten in the environment if
there is a config param of \fB<name>[@<version>]:<key>\fP\|\. For example,
if the package\.json has this:
.P
.RS 2
.nf
{
"name" : "foo",
"config" : {
"port" : "8080"
},
"scripts" : {
"start" : "node server\.js"
}
}
.fi
.RE
.P
and the server\.js is this:
.P
.RS 2
.nf
http\.createServer(\.\.\.)\.listen(process\.env\.npm_package_config_port)
.fi
.RE
.P
then the user could change the behavior by doing:
.P
.RS 2
.nf
npm config set foo:port 80
.fi
.RE
.SS current lifecycle event
.P
Lastly, the \fBnpm_lifecycle_event\fP environment variable is set to
whichever stage of the cycle is being executed\. So, you could have a
single script used for different parts of the process which switches
based on what's currently happening\.
.P
Objects are flattened following this format, so if you had
\fB{"scripts":{"install":"foo\.js"}}\fP in your package\.json, then you'd
see this in the script:
.P
.RS 2
.nf
process\.env\.npm_package_scripts_install === "foo\.js"
.fi
.RE
.SS Examples
.P
For example, if your package\.json contains this:
.P
.RS 2
.nf
{
"scripts" : {
"install" : "scripts/install\.js",
"postinstall" : "scripts/install\.js",
"uninstall" : "scripts/uninstall\.js"
}
}
.fi
.RE
.P
then \fBscripts/install\.js\fP will be called for the install
and post\-install stages of the lifecycle, and \fBscripts/uninstall\.js\fP
will be called when the package is uninstalled\. Since
\fBscripts/install\.js\fP is running for two different phases, it would
be wise in this case to look at the \fBnpm_lifecycle_event\fP environment
variable\.
.P
If you want to run a make command, you can do so\. This works just
fine:
.P
.RS 2
.nf
{
"scripts" : {
"preinstall" : "\./configure",
"install" : "make && make install",
"test" : "make test"
}
}
.fi
.RE
.SS Exiting
.P
Scripts are run by passing the line as a script argument to \fBsh\fP\|\.
.P
If the script exits with a code other than 0, then this will abort the
process\.
.P
Note that these script files don't have to be nodejs or even
javascript programs\. They just have to be some kind of executable
file\.
.SS Hook Scripts
.P
If you want to run a specific script at a specific lifecycle event for
ALL packages, then you can use a hook script\.
.P
Place an executable file at \fBnode_modules/\.hooks/{eventname}\fP, and
it'll get run for all packages when they are going through that point
in the package lifecycle for any packages installed in that root\.
.P
Hook scripts are run exactly the same way as package\.json scripts\.
That is, they are in a separate child process, with the env described
above\.
.SS Best Practices
.RS 0
.IP \(bu 2
Don't exit with a non\-zero error code unless you \fIreally\fR mean it\.
Except for uninstall scripts, this will cause the npm action to
fail, and potentially be rolled back\. If the failure is minor or
only will prevent some optional features, then it's better to just
print a warning and exit successfully\.
.IP \(bu 2
Try not to use scripts to do what npm can do for you\. Read through
npm help \fBpackage\.json\fP to see all the things that you can specify and enable
by simply describing your package appropriately\. In general, this
will lead to a more robust and consistent state\.
.IP \(bu 2
Inspect the env to determine where to put things\. For instance, if
the \fBnpm_config_binroot\fP environment variable is set to \fB/home/user/bin\fP, then
don't try to install executables into \fB/usr/local/bin\fP\|\. The user
probably set it up that way for a reason\.
.IP \(bu 2
Don't prefix your script commands with "sudo"\. If root permissions
are required for some reason, then it'll fail with that error, and
the user will sudo the npm command in question\.
.IP \(bu 2
Don't use \fBinstall\fP\|\. Use a \fB\|\.gyp\fP file for compilation, and \fBprepublish\fP
for anything else\. You should almost never have to explicitly set a
preinstall or install script\. If you are doing this, please consider if
there is another option\. The only valid use of \fBinstall\fP or \fBpreinstall\fP
scripts is for compilation which must be done on the target architecture\.
.RE
.SS See Also
.RS 0
.IP \(bu 2
npm help run\-script
.IP \(bu 2
npm help package\.json
.IP \(bu 2
npm help developers
.IP \(bu 2
npm help install
.RE

View File

@ -0,0 +1,510 @@
.TH "SEMVER" "7" "August 2021" "" ""
.SH "NAME"
\fBsemver\fR \- The semantic versioner for npm
.SH Install
.P
.RS 2
.nf
npm install \-\-save semver
.fi
.RE
.SH Usage
.P
As a node module:
.P
.RS 2
.nf
const semver = require('semver')
semver\.valid('1\.2\.3') // '1\.2\.3'
semver\.valid('a\.b\.c') // null
semver\.clean(' =v1\.2\.3 ') // '1\.2\.3'
semver\.satisfies('1\.2\.3', '1\.x || >=2\.5\.0 || 5\.0\.0 \- 7\.2\.3') // true
semver\.gt('1\.2\.3', '9\.8\.7') // false
semver\.lt('1\.2\.3', '9\.8\.7') // true
semver\.minVersion('>=1\.0\.0') // '1\.0\.0'
semver\.valid(semver\.coerce('v2')) // '2\.0\.0'
semver\.valid(semver\.coerce('42\.6\.7\.9\.3\-alpha')) // '42\.6\.7'
.fi
.RE
.P
As a command\-line utility:
.P
.RS 2
.nf
$ semver \-h
A JavaScript implementation of the https://semver\.org/ specification
Copyright Isaac Z\. Schlueter
Usage: semver [options] <version> [<version> [\.\.\.]]
Prints valid versions sorted by SemVer precedence
Options:
\-r \-\-range <range>
Print versions that match the specified range\.
\-i \-\-increment [<level>]
Increment a version by the specified level\. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, or prerelease\. Default level is 'patch'\.
Only one version may be specified\.
\-\-preid <identifier>
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments\.
\-l \-\-loose
Interpret versions and ranges loosely
\-p \-\-include\-prerelease
Always include prerelease versions in range matching
\-c \-\-coerce
Coerce a string into SemVer if possible
(does not imply \-\-loose)
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions\.
If no satisfying versions are found, then exits failure\.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them\.
.fi
.RE
.SH Versions
.P
A "version" is described by the \fBv2\.0\.0\fP specification found at
https://semver\.org/\|\.
.P
A leading \fB"="\fP or \fB"v"\fP character is stripped off and ignored\.
.SH Ranges
.P
A \fBversion range\fP is a set of \fBcomparators\fP which specify versions
that satisfy the range\.
.P
A \fBcomparator\fP is composed of an \fBoperator\fP and a \fBversion\fP\|\. The set
of primitive \fBoperators\fP is:
.RS 0
.IP \(bu 2
\fB<\fP Less than
.IP \(bu 2
\fB<=\fP Less than or equal to
.IP \(bu 2
\fB>\fP Greater than
.IP \(bu 2
\fB>=\fP Greater than or equal to
.IP \(bu 2
\fB=\fP Equal\. If no operator is specified, then equality is assumed,
so this operator is optional, but MAY be included\.
.RE
.P
For example, the comparator \fB>=1\.2\.7\fP would match the versions
\fB1\.2\.7\fP, \fB1\.2\.8\fP, \fB2\.5\.3\fP, and \fB1\.3\.9\fP, but not the versions \fB1\.2\.6\fP
or \fB1\.1\.0\fP\|\.
.P
Comparators can be joined by whitespace to form a \fBcomparator set\fP,
which is satisfied by the \fBintersection\fR of all of the comparators
it includes\.
.P
A range is composed of one or more comparator sets, joined by \fB||\fP\|\. A
version matches a range if and only if every comparator in at least
one of the \fB||\fP\-separated comparator sets is satisfied by the version\.
.P
For example, the range \fB>=1\.2\.7 <1\.3\.0\fP would match the versions
\fB1\.2\.7\fP, \fB1\.2\.8\fP, and \fB1\.2\.99\fP, but not the versions \fB1\.2\.6\fP, \fB1\.3\.0\fP,
or \fB1\.1\.0\fP\|\.
.P
The range \fB1\.2\.7 || >=1\.2\.9 <2\.0\.0\fP would match the versions \fB1\.2\.7\fP,
\fB1\.2\.9\fP, and \fB1\.4\.6\fP, but not the versions \fB1\.2\.8\fP or \fB2\.0\.0\fP\|\.
.SS Prerelease Tags
.P
If a version has a prerelease tag (for example, \fB1\.2\.3\-alpha\.3\fP) then
it will only be allowed to satisfy comparator sets if at least one
comparator with the same \fB[major, minor, patch]\fP tuple also has a
prerelease tag\.
.P
For example, the range \fB>1\.2\.3\-alpha\.3\fP would be allowed to match the
version \fB1\.2\.3\-alpha\.7\fP, but it would \fInot\fR be satisfied by
\fB3\.4\.5\-alpha\.9\fP, even though \fB3\.4\.5\-alpha\.9\fP is technically "greater
than" \fB1\.2\.3\-alpha\.3\fP according to the SemVer sort rules\. The version
range only accepts prerelease tags on the \fB1\.2\.3\fP version\. The
version \fB3\.4\.5\fP \fIwould\fR satisfy the range, because it does not have a
prerelease flag, and \fB3\.4\.5\fP is greater than \fB1\.2\.3\-alpha\.7\fP\|\.
.P
The purpose for this behavior is twofold\. First, prerelease versions
frequently are updated very quickly, and contain many breaking changes
that are (by the author's design) not yet fit for public consumption\.
Therefore, by default, they are excluded from range matching
semantics\.
.P
Second, a user who has opted into using a prerelease version has
clearly indicated the intent to use \fIthat specific\fR set of
alpha/beta/rc versions\. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk\. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the \fInext\fR set of prerelease versions\.
.P
Note that this behavior can be suppressed (treating all prerelease
versions as if they were normal versions, for the purpose of range
matching) by setting the \fBincludePrerelease\fP flag on the options
object to any
functions \fIhttps://github\.com/npm/node\-semver#functions\fR that do
range matching\.
.SS Prerelease Identifiers
.P
The method \fB\|\.inc\fP takes an additional \fBidentifier\fP string argument that
will append the value of the string as a prerelease identifier:
.P
.RS 2
.nf
semver\.inc('1\.2\.3', 'prerelease', 'beta')
// '1\.2\.4\-beta\.0'
.fi
.RE
.P
command\-line example:
.P
.RS 2
.nf
$ semver 1\.2\.3 \-i prerelease \-\-preid beta
1\.2\.4\-beta\.0
.fi
.RE
.P
Which then can be used to increment further:
.P
.RS 2
.nf
$ semver 1\.2\.4\-beta\.0 \-i prerelease
1\.2\.4\-beta\.1
.fi
.RE
.SS Advanced Range Syntax
.P
Advanced range syntax desugars to primitive comparators in
deterministic ways\.
.P
Advanced ranges may be combined in the same way as primitive
comparators using white space or \fB||\fP\|\.
.SS Hyphen Ranges \fBX\.Y\.Z \- A\.B\.C\fP
.P
Specifies an inclusive set\.
.RS 0
.IP \(bu 2
\fB1\.2\.3 \- 2\.3\.4\fP := \fB>=1\.2\.3 <=2\.3\.4\fP
.RE
.P
If a partial version is provided as the first version in the inclusive
range, then the missing pieces are replaced with zeroes\.
.RS 0
.IP \(bu 2
\fB1\.2 \- 2\.3\.4\fP := \fB>=1\.2\.0 <=2\.3\.4\fP
.RE
.P
If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts\.
.RS 0
.IP \(bu 2
\fB1\.2\.3 \- 2\.3\fP := \fB>=1\.2\.3 <2\.4\.0\fP
.IP \(bu 2
\fB1\.2\.3 \- 2\fP := \fB>=1\.2\.3 <3\.0\.0\fP
.RE
.SS X\-Ranges \fB1\.2\.x\fP \fB1\.X\fP \fB1\.2\.*\fP \fB*\fP
.P
Any of \fBX\fP, \fBx\fP, or \fB*\fP may be used to "stand in" for one of the
numeric values in the \fB[major, minor, patch]\fP tuple\.
.RS 0
.IP \(bu 2
\fB*\fP := \fB>=0\.0\.0\fP (Any version satisfies)
.IP \(bu 2
\fB1\.x\fP := \fB>=1\.0\.0 <2\.0\.0\fP (Matching major version)
.IP \(bu 2
\fB1\.2\.x\fP := \fB>=1\.2\.0 <1\.3\.0\fP (Matching major and minor versions)
.RE
.P
A partial version range is treated as an X\-Range, so the special
character is in fact optional\.
.RS 0
.IP \(bu 2
\fB""\fP (empty string) := \fB*\fP := \fB>=0\.0\.0\fP
.IP \(bu 2
\fB1\fP := \fB1\.x\.x\fP := \fB>=1\.0\.0 <2\.0\.0\fP
.IP \(bu 2
\fB1\.2\fP := \fB1\.2\.x\fP := \fB>=1\.2\.0 <1\.3\.0\fP
.RE
.SS Tilde Ranges \fB~1\.2\.3\fP \fB~1\.2\fP \fB~1\fP
.P
Allows patch\-level changes if a minor version is specified on the
comparator\. Allows minor\-level changes if not\.
.RS 0
.IP \(bu 2
\fB~1\.2\.3\fP := \fB>=1\.2\.3 <1\.(2+1)\.0\fP := \fB>=1\.2\.3 <1\.3\.0\fP
.IP \(bu 2
\fB~1\.2\fP := \fB>=1\.2\.0 <1\.(2+1)\.0\fP := \fB>=1\.2\.0 <1\.3\.0\fP (Same as \fB1\.2\.x\fP)
.IP \(bu 2
\fB~1\fP := \fB>=1\.0\.0 <(1+1)\.0\.0\fP := \fB>=1\.0\.0 <2\.0\.0\fP (Same as \fB1\.x\fP)
.IP \(bu 2
\fB~0\.2\.3\fP := \fB>=0\.2\.3 <0\.(2+1)\.0\fP := \fB>=0\.2\.3 <0\.3\.0\fP
.IP \(bu 2
\fB~0\.2\fP := \fB>=0\.2\.0 <0\.(2+1)\.0\fP := \fB>=0\.2\.0 <0\.3\.0\fP (Same as \fB0\.2\.x\fP)
.IP \(bu 2
\fB~0\fP := \fB>=0\.0\.0 <(0+1)\.0\.0\fP := \fB>=0\.0\.0 <1\.0\.0\fP (Same as \fB0\.x\fP)
.IP \(bu 2
\fB~1\.2\.3\-beta\.2\fP := \fB>=1\.2\.3\-beta\.2 <1\.3\.0\fP Note that prereleases in
the \fB1\.2\.3\fP version will be allowed, if they are greater than or
equal to \fBbeta\.2\fP\|\. So, \fB1\.2\.3\-beta\.4\fP would be allowed, but
\fB1\.2\.4\-beta\.2\fP would not, because it is a prerelease of a
different \fB[major, minor, patch]\fP tuple\.
.RE
.SS Caret Ranges \fB^1\.2\.3\fP \fB^0\.2\.5\fP \fB^0\.0\.4\fP
.P
Allows changes that do not modify the left\-most non\-zero digit in the
\fB[major, minor, patch]\fP tuple\. In other words, this allows patch and
minor updates for versions \fB1\.0\.0\fP and above, patch updates for
versions \fB0\.X >=0\.1\.0\fP, and \fIno\fR updates for versions \fB0\.0\.X\fP\|\.
.P
Many authors treat a \fB0\.x\fP version as if the \fBx\fP were the major
"breaking\-change" indicator\.
.P
Caret ranges are ideal when an author may make breaking changes
between \fB0\.2\.4\fP and \fB0\.3\.0\fP releases, which is a common practice\.
However, it presumes that there will \fInot\fR be breaking changes between
\fB0\.2\.4\fP and \fB0\.2\.5\fP\|\. It allows for changes that are presumed to be
additive (but non\-breaking), according to commonly observed practices\.
.RS 0
.IP \(bu 2
\fB^1\.2\.3\fP := \fB>=1\.2\.3 <2\.0\.0\fP
.IP \(bu 2
\fB^0\.2\.3\fP := \fB>=0\.2\.3 <0\.3\.0\fP
.IP \(bu 2
\fB^0\.0\.3\fP := \fB>=0\.0\.3 <0\.0\.4\fP
.IP \(bu 2
\fB^1\.2\.3\-beta\.2\fP := \fB>=1\.2\.3\-beta\.2 <2\.0\.0\fP Note that prereleases in
the \fB1\.2\.3\fP version will be allowed, if they are greater than or
equal to \fBbeta\.2\fP\|\. So, \fB1\.2\.3\-beta\.4\fP would be allowed, but
\fB1\.2\.4\-beta\.2\fP would not, because it is a prerelease of a
different \fB[major, minor, patch]\fP tuple\.
.IP \(bu 2
\fB^0\.0\.3\-beta\fP := \fB>=0\.0\.3\-beta <0\.0\.4\fP Note that prereleases in the
\fB0\.0\.3\fP version \fIonly\fR will be allowed, if they are greater than or
equal to \fBbeta\fP\|\. So, \fB0\.0\.3\-pr\.2\fP would be allowed\.
.RE
.P
When parsing caret ranges, a missing \fBpatch\fP value desugars to the
number \fB0\fP, but will allow flexibility within that value, even if the
major and minor versions are both \fB0\fP\|\.
.RS 0
.IP \(bu 2
\fB^1\.2\.x\fP := \fB>=1\.2\.0 <2\.0\.0\fP
.IP \(bu 2
\fB^0\.0\.x\fP := \fB>=0\.0\.0 <0\.1\.0\fP
.IP \(bu 2
\fB^0\.0\fP := \fB>=0\.0\.0 <0\.1\.0\fP
.RE
.P
A missing \fBminor\fP and \fBpatch\fP values will desugar to zero, but also
allow flexibility within those values, even if the major version is
zero\.
.RS 0
.IP \(bu 2
\fB^1\.x\fP := \fB>=1\.0\.0 <2\.0\.0\fP
.IP \(bu 2
\fB^0\.x\fP := \fB>=0\.0\.0 <1\.0\.0\fP
.RE
.SS Range Grammar
.P
Putting all this together, here is a Backus\-Naur grammar for ranges,
for the benefit of parser authors:
.P
.RS 2
.nf
range\-set ::= range ( logical\-or range ) *
logical\-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' \- ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '\.' xr ( '\.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'\-'9'] ( ['0'\-'9'] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '\-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '\.' part ) *
part ::= nr | [\-0\-9A\-Za\-z]+
.fi
.RE
.SH Functions
.P
All methods and classes take a final \fBoptions\fP object argument\. All
options in this object are \fBfalse\fP by default\. The options supported
are:
.RS 0
.IP \(bu 2
\fBloose\fP Be more forgiving about not\-quite\-valid semver strings\.
(Any resulting output will always be 100% strict compliant, of
course\.) For backwards compatibility reasons, if the \fBoptions\fP
argument is a boolean value instead of an object, it is interpreted
to be the \fBloose\fP param\.
.IP \(bu 2
\fBincludePrerelease\fP Set to suppress the default
behavior \fIhttps://github\.com/npm/node\-semver#prerelease\-tags\fR of
excluding prerelease tagged versions from ranges unless they are
explicitly opted into\.
.RE
.P
Strict\-mode Comparators and Ranges will be strict about the SemVer
strings that they parse\.
.RS 0
.IP \(bu 2
\fBvalid(v)\fP: Return the parsed version, or null if it's not valid\.
.IP \(bu 2
\fBinc(v, release)\fP: Return the version incremented by the release
type (\fBmajor\fP, \fBpremajor\fP, \fBminor\fP, \fBpreminor\fP, \fBpatch\fP,
\fBprepatch\fP, or \fBprerelease\fP), or null if it's not valid
.RS
.IP \(bu 2
\fBpremajor\fP in one call will bump the version up to the next major
version and down to a prerelease of that major version\.
\fBpreminor\fP, and \fBprepatch\fP work the same way\.
.IP \(bu 2
If called from a non\-prerelease version, the \fBprerelease\fP will work the
same as \fBprepatch\fP\|\. It increments the patch version, then makes a
prerelease\. If the input version is already a prerelease it simply
increments it\.
.RE
.IP \(bu 2
\fBprerelease(v)\fP: Returns an array of prerelease components, or null
if none exist\. Example: \fBprerelease('1\.2\.3\-alpha\.1') \-> ['alpha', 1]\fP
.IP \(bu 2
\fBmajor(v)\fP: Return the major version number\.
.IP \(bu 2
\fBminor(v)\fP: Return the minor version number\.
.IP \(bu 2
\fBpatch(v)\fP: Return the patch version number\.
.IP \(bu 2
\fBintersects(r1, r2, loose)\fP: Return true if the two supplied ranges
or comparators intersect\.
.IP \(bu 2
\fBparse(v)\fP: Attempt to parse a string as a semantic version, returning either
a \fBSemVer\fP object or \fBnull\fP\|\.
.RE
.SS Comparison
.RS 0
.IP \(bu 2
\fBgt(v1, v2)\fP: \fBv1 > v2\fP
.IP \(bu 2
\fBgte(v1, v2)\fP: \fBv1 >= v2\fP
.IP \(bu 2
\fBlt(v1, v2)\fP: \fBv1 < v2\fP
.IP \(bu 2
\fBlte(v1, v2)\fP: \fBv1 <= v2\fP
.IP \(bu 2
\fBeq(v1, v2)\fP: \fBv1 == v2\fP This is true if they're logically equivalent,
even if they're not the exact same string\. You already know how to
compare strings\.
.IP \(bu 2
\fBneq(v1, v2)\fP: \fBv1 != v2\fP The opposite of \fBeq\fP\|\.
.IP \(bu 2
\fBcmp(v1, comparator, v2)\fP: Pass in a comparison string, and it'll call
the corresponding function above\. \fB"==="\fP and \fB"!=="\fP do simple
string comparison, but are included for completeness\. Throws if an
invalid comparison string is provided\.
.IP \(bu 2
\fBcompare(v1, v2)\fP: Return \fB0\fP if \fBv1 == v2\fP, or \fB1\fP if \fBv1\fP is greater, or \fB\-1\fP if
\fBv2\fP is greater\. Sorts in ascending order if passed to \fBArray\.sort()\fP\|\.
.IP \(bu 2
\fBrcompare(v1, v2)\fP: The reverse of compare\. Sorts an array of versions
in descending order when passed to \fBArray\.sort()\fP\|\.
.IP \(bu 2
\fBdiff(v1, v2)\fP: Returns difference between two versions by the release type
(\fBmajor\fP, \fBpremajor\fP, \fBminor\fP, \fBpreminor\fP, \fBpatch\fP, \fBprepatch\fP, or \fBprerelease\fP),
or null if the versions are the same\.
.RE
.SS Comparators
.RS 0
.IP \(bu 2
\fBintersects(comparator)\fP: Return true if the comparators intersect
.RE
.SS Ranges
.RS 0
.IP \(bu 2
\fBvalidRange(range)\fP: Return the valid range or null if it's not valid
.IP \(bu 2
\fBsatisfies(version, range)\fP: Return true if the version satisfies the
range\.
.IP \(bu 2
\fBmaxSatisfying(versions, range)\fP: Return the highest version in the list
that satisfies the range, or \fBnull\fP if none of them do\.
.IP \(bu 2
\fBminSatisfying(versions, range)\fP: Return the lowest version in the list
that satisfies the range, or \fBnull\fP if none of them do\.
.IP \(bu 2
\fBminVersion(range)\fP: Return the lowest version that can possibly match
the given range\.
.IP \(bu 2
\fBgtr(version, range)\fP: Return \fBtrue\fP if version is greater than all the
versions possible in the range\.
.IP \(bu 2
\fBltr(version, range)\fP: Return \fBtrue\fP if version is less than all the
versions possible in the range\.
.IP \(bu 2
\fBoutside(version, range, hilo)\fP: Return true if the version is outside
the bounds of the range in either the high or low direction\. The
\fBhilo\fP argument must be either the string \fB\|'>'\fP or \fB\|'<'\fP\|\. (This is
the function called by \fBgtr\fP and \fBltr\fP\|\.)
.IP \(bu 2
\fBintersects(range)\fP: Return true if any of the ranges comparators intersect
.RE
.P
Note that, since ranges may be non\-contiguous, a version might not be
greater than a range, less than a range, \fIor\fR satisfy a range! For
example, the range \fB1\.2 <1\.2\.9 || >2\.0\.0\fP would have a hole from \fB1\.2\.9\fP
until \fB2\.0\.0\fP, so the version \fB1\.2\.10\fP would not be greater than the
range (because \fB2\.0\.1\fP satisfies, which is higher), nor less than the
range (since \fB1\.2\.8\fP satisfies, which is lower), and it also does not
satisfy the range\.
.P
If you want to know if a version satisfies or does not satisfy a
range, use the \fBsatisfies(version, range)\fP function\.
.SS Coercion
.RS 0
.IP \(bu 2
\fBcoerce(version)\fP: Coerces a string to semver if possible
.RE
.P
This aims to provide a very forgiving translation of a non\-semver string to
semver\. It looks for the first digit in a string, and consumes all
remaining characters which satisfy at least a partial semver (e\.g\., \fB1\fP,
\fB1\.2\fP, \fB1\.2\.3\fP) up to the max permitted length (256 characters)\. Longer
versions are simply truncated (\fB4\.6\.3\.9\.2\-alpha2\fP becomes \fB4\.6\.3\fP)\. All
surrounding text is simply ignored (\fBv3\.4 replaces v3\.3\.1\fP becomes
\fB3\.4\.0\fP)\. Only text which lacks digits will fail coercion (\fBversion one\fP
is not valid)\. The maximum length for any semver component considered for
coercion is 16 characters; longer components will be ignored
(\fB10000000000000000\.4\.7\.4\fP becomes \fB4\.7\.4\fP)\. The maximum value for any
semver component is \fBNumber\.MAX_SAFE_INTEGER || (2**53 \- 1)\fP; higher value
components are invalid (\fB9999999999999999\.4\.7\.4\fP is likely invalid)\.