ReactFlow前端拖拽模型与参数配置功能MVP
This commit is contained in:
1 parent
70c91ed019
commit
d3b99304fb
2001 files changed
+349044
-548
No files matched your search
Whitespace-only changes.
+235
@@ -0,0 +1,235 @@
|
||||
The npm application
|
||||
Copyright (c) npm, Inc. and Contributors
|
||||
Licensed on the terms of The Artistic License 2.0
|
||||
|
||||
Node package dependencies of the npm application
|
||||
Copyright (c) their respective copyright owners
|
||||
Licensed on their respective license terms
|
||||
|
||||
The npm public registry at https://registry.npmjs.org
|
||||
and the npm website at https://www.npmjs.com
|
||||
Operated by npm, Inc.
|
||||
Use governed by terms published on https://www.npmjs.com
|
||||
|
||||
"Node.js"
|
||||
Trademark Joyent, Inc., https://joyent.com
|
||||
Neither npm nor npm, Inc. are affiliated with Joyent, Inc.
|
||||
|
||||
The Node.js application
|
||||
Project of Node Foundation, https://nodejs.org
|
||||
|
||||
The npm Logo
|
||||
Copyright (c) Mathias Pettersson and Brian Hammond
|
||||
|
||||
"Gubblebum Blocky" typeface
|
||||
Copyright (c) Tjarda Koster, https://jelloween.deviantart.com
|
||||
Used with permission
|
||||
|
||||
|
||||
--------
|
||||
|
||||
|
||||
The Artistic License 2.0
|
||||
|
||||
Copyright (c) 2000-2006, The Perl Foundation.
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
This license establishes the terms under which a given free software
|
||||
Package may be copied, modified, distributed, and/or redistributed.
|
||||
The intent is that the Copyright Holder maintains some artistic
|
||||
control over the development of that Package while still keeping the
|
||||
Package available as open source and free software.
|
||||
|
||||
You are always permitted to make arrangements wholly outside of this
|
||||
license directly with the Copyright Holder of a given Package. If the
|
||||
terms of this license do not permit the full use that you propose to
|
||||
make of the Package, you should contact the Copyright Holder and seek
|
||||
a different licensing arrangement.
|
||||
|
||||
Definitions
|
||||
|
||||
"Copyright Holder" means the individual(s) or organization(s)
|
||||
named in the copyright notice for the entire Package.
|
||||
|
||||
"Contributor" means any party that has contributed code or other
|
||||
material to the Package, in accordance with the Copyright Holder's
|
||||
procedures.
|
||||
|
||||
"You" and "your" means any person who would like to copy,
|
||||
distribute, or modify the Package.
|
||||
|
||||
"Package" means the collection of files distributed by the
|
||||
Copyright Holder, and derivatives of that collection and/or of
|
||||
those files. A given Package may consist of either the Standard
|
||||
Version, or a Modified Version.
|
||||
|
||||
"Distribute" means providing a copy of the Package or making it
|
||||
accessible to anyone else, or in the case of a company or
|
||||
organization, to others outside of your company or organization.
|
||||
|
||||
"Distributor Fee" means any fee that you charge for Distributing
|
||||
this Package or providing support for this Package to another
|
||||
party. It does not mean licensing fees.
|
||||
|
||||
"Standard Version" refers to the Package if it has not been
|
||||
modified, or has been modified only in ways explicitly requested
|
||||
by the Copyright Holder.
|
||||
|
||||
"Modified Version" means the Package, if it has been changed, and
|
||||
such changes were not explicitly requested by the Copyright
|
||||
Holder.
|
||||
|
||||
"Original License" means this Artistic License as Distributed with
|
||||
the Standard Version of the Package, in its current version or as
|
||||
it may be modified by The Perl Foundation in the future.
|
||||
|
||||
"Source" form means the source code, documentation source, and
|
||||
configuration files for the Package.
|
||||
|
||||
"Compiled" form means the compiled bytecode, object code, binary,
|
||||
or any other form resulting from mechanical transformation or
|
||||
translation of the Source form.
|
||||
|
||||
|
||||
Permission for Use and Modification Without Distribution
|
||||
|
||||
(1) You are permitted to use the Standard Version and create and use
|
||||
Modified Versions for any purpose without restriction, provided that
|
||||
you do not Distribute the Modified Version.
|
||||
|
||||
|
||||
Permissions for Redistribution of the Standard Version
|
||||
|
||||
(2) You may Distribute verbatim copies of the Source form of the
|
||||
Standard Version of this Package in any medium without restriction,
|
||||
either gratis or for a Distributor Fee, provided that you duplicate
|
||||
all of the original copyright notices and associated disclaimers. At
|
||||
your discretion, such verbatim copies may or may not include a
|
||||
Compiled form of the Package.
|
||||
|
||||
(3) You may apply any bug fixes, portability changes, and other
|
||||
modifications made available from the Copyright Holder. The resulting
|
||||
Package will still be considered the Standard Version, and as such
|
||||
will be subject to the Original License.
|
||||
|
||||
|
||||
Distribution of Modified Versions of the Package as Source
|
||||
|
||||
(4) You may Distribute your Modified Version as Source (either gratis
|
||||
or for a Distributor Fee, and with or without a Compiled form of the
|
||||
Modified Version) provided that you clearly document how it differs
|
||||
from the Standard Version, including, but not limited to, documenting
|
||||
any non-standard features, executables, or modules, and provided that
|
||||
you do at least ONE of the following:
|
||||
|
||||
(a) make the Modified Version available to the Copyright Holder
|
||||
of the Standard Version, under the Original License, so that the
|
||||
Copyright Holder may include your modifications in the Standard
|
||||
Version.
|
||||
|
||||
(b) ensure that installation of your Modified Version does not
|
||||
prevent the user installing or running the Standard Version. In
|
||||
addition, the Modified Version must bear a name that is different
|
||||
from the name of the Standard Version.
|
||||
|
||||
(c) allow anyone who receives a copy of the Modified Version to
|
||||
make the Source form of the Modified Version available to others
|
||||
under
|
||||
|
||||
(i) the Original License or
|
||||
|
||||
(ii) a license that permits the licensee to freely copy,
|
||||
modify and redistribute the Modified Version using the same
|
||||
licensing terms that apply to the copy that the licensee
|
||||
received, and requires that the Source form of the Modified
|
||||
Version, and of any works derived from it, be made freely
|
||||
available in that license fees are prohibited but Distributor
|
||||
Fees are allowed.
|
||||
|
||||
|
||||
Distribution of Compiled Forms of the Standard Version
|
||||
or Modified Versions without the Source
|
||||
|
||||
(5) You may Distribute Compiled forms of the Standard Version without
|
||||
the Source, provided that you include complete instructions on how to
|
||||
get the Source of the Standard Version. Such instructions must be
|
||||
valid at the time of your distribution. If these instructions, at any
|
||||
time while you are carrying out such distribution, become invalid, you
|
||||
must provide new instructions on demand or cease further distribution.
|
||||
If you provide valid instructions or cease distribution within thirty
|
||||
days after you become aware that the instructions are invalid, then
|
||||
you do not forfeit any of your rights under this license.
|
||||
|
||||
(6) You may Distribute a Modified Version in Compiled form without
|
||||
the Source, provided that you comply with Section 4 with respect to
|
||||
the Source of the Modified Version.
|
||||
|
||||
|
||||
Aggregating or Linking the Package
|
||||
|
||||
(7) You may aggregate the Package (either the Standard Version or
|
||||
Modified Version) with other packages and Distribute the resulting
|
||||
aggregation provided that you do not charge a licensing fee for the
|
||||
Package. Distributor Fees are permitted, and licensing fees for other
|
||||
components in the aggregation are permitted. The terms of this license
|
||||
apply to the use and Distribution of the Standard or Modified Versions
|
||||
as included in the aggregation.
|
||||
|
||||
(8) You are permitted to link Modified and Standard Versions with
|
||||
other works, to embed the Package in a larger work of your own, or to
|
||||
build stand-alone binary or bytecode versions of applications that
|
||||
include the Package, and Distribute the result without restriction,
|
||||
provided the result does not expose a direct interface to the Package.
|
||||
|
||||
|
||||
Items That are Not Considered Part of a Modified Version
|
||||
|
||||
(9) Works (including, but not limited to, modules and scripts) that
|
||||
merely extend or make use of the Package, do not, by themselves, cause
|
||||
the Package to be a Modified Version. In addition, such works are not
|
||||
considered parts of the Package itself, and are not subject to the
|
||||
terms of this license.
|
||||
|
||||
|
||||
General Provisions
|
||||
|
||||
(10) Any use, modification, and distribution of the Standard or
|
||||
Modified Versions is governed by this Artistic License. By using,
|
||||
modifying or distributing the Package, you accept this license. Do not
|
||||
use, modify, or distribute the Package, if you do not accept this
|
||||
license.
|
||||
|
||||
(11) If your Modified Version has been derived from a Modified
|
||||
Version made by someone other than you, you are nevertheless required
|
||||
to ensure that your Modified Version complies with the requirements of
|
||||
this license.
|
||||
|
||||
(12) This license does not grant you the right to use any trademark,
|
||||
service mark, tradename, or logo of the Copyright Holder.
|
||||
|
||||
(13) This license includes the non-exclusive, worldwide,
|
||||
free-of-charge patent license to make, have made, use, offer to sell,
|
||||
sell, import and otherwise transfer the Package with respect to any
|
||||
patent claims licensable by the Copyright Holder that are necessarily
|
||||
infringed by the Package. If you institute patent litigation
|
||||
(including a cross-claim or counterclaim) against any party alleging
|
||||
that the Package constitutes direct or contributory patent
|
||||
infringement, then this Artistic License to you shall terminate on the
|
||||
date that such litigation is filed.
|
||||
|
||||
(14) Disclaimer of Warranty:
|
||||
THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
|
||||
IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL
|
||||
LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
--------
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
# npm - a JavaScript package manager
|
||||
|
||||
### Requirements
|
||||
|
||||
You should be running a currently supported version of [Node.js](https://nodejs.org/en/download/) to run **`npm`**. For a list of which versions of Node.js are currently supported, please see the [Node.js releases](https://nodejs.org/en/about/previous-releases) page.
|
||||
|
||||
### Installation
|
||||
|
||||
**`npm`** comes bundled with [**`node`**](https://nodejs.org/), & most third-party distributions, by default. Officially supported downloads/distributions can be found at: [nodejs.org/en/download](https://nodejs.org/en/download)
|
||||
|
||||
#### Direct Download
|
||||
|
||||
You can download & install **`npm`** directly from [**npmjs**.com](https://npmjs.com/) using our custom `install.sh` script:
|
||||
|
||||
```bash
|
||||
curl -qL https://www.npmjs.com/install.sh | sh
|
||||
```
|
||||
|
||||
#### Node Version Managers
|
||||
|
||||
If you're looking to manage multiple versions of **`Node.js`** &/or **`npm`**, consider using a [node version manager](https://github.com/search?q=node+version+manager+archived%3Afalse&type=repositories&ref=advsearch)
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
npm <command>
|
||||
```
|
||||
|
||||
### Links & Resources
|
||||
|
||||
* [**Documentation**](https://docs.npmjs.com/) - Official docs & how-tos for all things **npm**
|
||||
* Note: you can also search docs locally with `npm help-search <query>`
|
||||
* [**Bug Tracker**](https://github.com/npm/cli/issues) - Search or submit bugs against the CLI
|
||||
* [**Community Feedback and Discussions**](https://github.com/orgs/community/discussions/categories/npm) - Contribute ideas & discussion around the npm registry, website & CLI
|
||||
* [**RFCs**](https://github.com/npm/rfcs) - Contribute ideas & specifications for the API/design of the npm CLI
|
||||
* [**Service Status**](https://status.npmjs.org/) - Monitor the current status & see incident reports for the website & registry
|
||||
* [**Project Status**](https://npm.github.io/statusboard/) - See the health of all our maintained OSS projects in one view
|
||||
* [**Support**](https://www.npmjs.com/support) - Experiencing problems with the **npm** [website](https://npmjs.com) or [registry](https://registry.npmjs.org)? [File a ticket](https://www.npmjs.com/support)
|
||||
|
||||
### Acknowledgments
|
||||
|
||||
* `npm` is configured to use the **npm Public Registry** at [https://registry.npmjs.org](https://registry.npmjs.org) by default; Usage of this registry is subject to **Terms of Use** available at [https://npmjs.com/policies/terms](https://npmjs.com/policies/terms)
|
||||
* You can configure `npm` to use any other compatible registry you prefer. You can read more about [configuring third-party registries](https://docs.npmjs.com/cli/v7/using-npm/registry)
|
||||
|
||||
### FAQ on Branding
|
||||
|
||||
#### Is it "npm" or "NPM" or "Npm"?
|
||||
|
||||
**`npm`** should never be capitalized unless it is being displayed in a location that is customarily all-capitals (ex. titles on `man` pages).
|
||||
|
||||
#### Is "npm" an acronym for "Node Package Manager"?
|
||||
|
||||
Contrary to popular belief, **`npm`** **is not** an acronym for "Node Package Manager." It is a recursive backronymic abbreviation for **"npm is not an acronym"** (if the project were named "ninaa," then it would be an acronym). The precursor to **`npm`** was actually a bash utility named **"pm"**, which was the shortform name of **"pkgmakeinst"** - a bash function that installed various things on various platforms. If **`npm`** were ever considered an acronym, it would be as "node pm" or, potentially, "new pm".
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env sh
|
||||
if [ "x$npm_config_node_gyp" = "x" ]; then
|
||||
node "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js" "$@"
|
||||
else
|
||||
"$npm_config_node_gyp" "$@"
|
||||
fi
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
if not defined npm_config_node_gyp (
|
||||
node "%~dp0\..\..\node_modules\node-gyp\bin\node-gyp.js" %*
|
||||
) else (
|
||||
node "%npm_config_node_gyp%" %*
|
||||
)
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is used by the Node.js installer, which expects the cygwin/mingw
|
||||
# shell script to already be present in the npm dependency folder.
|
||||
|
||||
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
|
||||
|
||||
basedir=`dirname "$0"`
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
|
||||
IS_WSL="true"
|
||||
fi
|
||||
|
||||
function no_node_dir {
|
||||
# if this didn't work, then everything else below will fail
|
||||
echo "Could not determine Node.js install directory" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
NODE_EXE="$basedir/node.exe"
|
||||
if ! [ -x "$NODE_EXE" ]; then
|
||||
NODE_EXE="$basedir/node"
|
||||
fi
|
||||
if ! [ -x "$NODE_EXE" ]; then
|
||||
NODE_EXE=node
|
||||
fi
|
||||
|
||||
# this path is passed to node.exe, so it needs to match whatever
|
||||
# kind of paths Node.js thinks it's using, typically win32 paths.
|
||||
CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
|
||||
if [ $? -ne 0 ]; then
|
||||
# this fails under WSL 1 so add an additional message. we also suppress stderr above
|
||||
# because the actual error raised is not helpful. in WSL 1 node.exe cannot handle
|
||||
# output redirection properly. See https://github.com/microsoft/WSL/issues/2370
|
||||
if [ "$IS_WSL" == "true" ]; then
|
||||
echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
|
||||
fi
|
||||
no_node_dir
|
||||
fi
|
||||
NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"
|
||||
NPM_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-cli.js"
|
||||
NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`
|
||||
if [ $? -ne 0 ]; then
|
||||
no_node_dir
|
||||
fi
|
||||
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
|
||||
|
||||
# a path that will fail -f test on any posix bash
|
||||
NPM_WSL_PATH="/.."
|
||||
|
||||
# WSL can run Windows binaries, so we have to give it the win32 path
|
||||
# however, WSL bash tests against posix paths, so we need to construct that
|
||||
# to know if npm is installed globally.
|
||||
if [ "$IS_WSL" == "true" ]; then
|
||||
NPM_WSL_PATH=`wslpath "$NPM_PREFIX_NPM_CLI_JS"`
|
||||
fi
|
||||
if [ -f "$NPM_PREFIX_NPM_CLI_JS" ] || [ -f "$NPM_WSL_PATH" ]; then
|
||||
NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
|
||||
fi
|
||||
|
||||
"$NODE_EXE" "$NPM_CLI_JS" "$@"
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('../lib/cli.js')(process)
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env node
|
||||
// This is a single-use bin to help windows discover the proper prefix for npm
|
||||
// without having to load all of npm first
|
||||
// It does not accept argv params
|
||||
|
||||
const path = require('node:path')
|
||||
const Config = require('@npmcli/config')
|
||||
const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions')
|
||||
const config = new Config({
|
||||
npmPath: path.dirname(__dirname),
|
||||
// argv is explicitly not looked at since prefix is not something that can be changed via argv
|
||||
argv: [],
|
||||
definitions,
|
||||
flatten,
|
||||
shorthands,
|
||||
excludeNpmCwd: false,
|
||||
})
|
||||
|
||||
async function main () {
|
||||
try {
|
||||
await config.load()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(config.globalPrefix)
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
main()
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
:: Created by npm, please don't edit manually.
|
||||
@ECHO OFF
|
||||
|
||||
SETLOCAL
|
||||
|
||||
SET "NODE_EXE=%~dp0\node.exe"
|
||||
IF NOT EXIST "%NODE_EXE%" (
|
||||
SET "NODE_EXE=node"
|
||||
)
|
||||
|
||||
SET "NPM_PREFIX_JS=%~dp0\node_modules\npm\bin\npm-prefix.js"
|
||||
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
|
||||
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (
|
||||
SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
|
||||
)
|
||||
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
|
||||
SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
|
||||
)
|
||||
|
||||
"%NODE_EXE%" "%NPM_CLI_JS%" %*
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
Set-StrictMode -Version 'Latest'
|
||||
|
||||
$NODE_EXE="$PSScriptRoot/node.exe"
|
||||
if (-not (Test-Path $NODE_EXE)) {
|
||||
$NODE_EXE="$PSScriptRoot/node"
|
||||
}
|
||||
if (-not (Test-Path $NODE_EXE)) {
|
||||
$NODE_EXE="node"
|
||||
}
|
||||
|
||||
$NPM_PREFIX_JS="$PSScriptRoot/node_modules/npm/bin/npm-prefix.js"
|
||||
$NPM_CLI_JS="$PSScriptRoot/node_modules/npm/bin/npm-cli.js"
|
||||
$NPM_PREFIX=(& $NODE_EXE $NPM_PREFIX_JS)
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Could not determine Node.js install directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
|
||||
if (Test-Path $NPM_PREFIX_NPM_CLI_JS) {
|
||||
$NPM_CLI_JS=$NPM_PREFIX_NPM_CLI_JS
|
||||
}
|
||||
|
||||
if ($MyInvocation.ExpectingInput) { # takes pipeline input
|
||||
$input | & $NODE_EXE $NPM_CLI_JS $args
|
||||
} elseif (-not $MyInvocation.Line) { # used "-File" argument
|
||||
& $NODE_EXE $NPM_CLI_JS $args
|
||||
} else { # used "-Command" argument
|
||||
if (($MyInvocation | Get-Member -Name 'Statement') -and $MyInvocation.Statement) {
|
||||
$NPM_ORIGINAL_COMMAND = $MyInvocation.Statement
|
||||
} else {
|
||||
$NPM_ORIGINAL_COMMAND = (
|
||||
[Management.Automation.InvocationInfo].GetProperty('ScriptPosition', [Reflection.BindingFlags] 'Instance, NonPublic')
|
||||
).GetValue($MyInvocation).Text
|
||||
}
|
||||
|
||||
$NODE_EXE = $NODE_EXE.Replace("``", "````")
|
||||
$NPM_CLI_JS = $NPM_CLI_JS.Replace("``", "````")
|
||||
|
||||
$NPM_COMMAND_ARRAY = [Management.Automation.Language.Parser]::ParseInput($NPM_ORIGINAL_COMMAND, [ref] $null, [ref] $null).
|
||||
EndBlock.Statements.PipelineElements.CommandElements.Extent.Text
|
||||
$NPM_ARGS = ($NPM_COMMAND_ARRAY | Select-Object -Skip 1) -join ' '
|
||||
|
||||
Invoke-Expression "& `"$NODE_EXE`" `"$NPM_CLI_JS`" $NPM_ARGS"
|
||||
}
|
||||
|
||||
exit $LASTEXITCODE
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is used by the Node.js installer, which expects the cygwin/mingw
|
||||
# shell script to already be present in the npm dependency folder.
|
||||
|
||||
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
|
||||
|
||||
basedir=`dirname "$0"`
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
|
||||
IS_WSL="true"
|
||||
fi
|
||||
|
||||
function no_node_dir {
|
||||
# if this didn't work, then everything else below will fail
|
||||
echo "Could not determine Node.js install directory" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
NODE_EXE="$basedir/node.exe"
|
||||
if ! [ -x "$NODE_EXE" ]; then
|
||||
NODE_EXE="$basedir/node"
|
||||
fi
|
||||
if ! [ -x "$NODE_EXE" ]; then
|
||||
NODE_EXE=node
|
||||
fi
|
||||
|
||||
# this path is passed to node.exe, so it needs to match whatever
|
||||
# kind of paths Node.js thinks it's using, typically win32 paths.
|
||||
CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
|
||||
if [ $? -ne 0 ]; then
|
||||
# this fails under WSL 1 so add an additional message. we also suppress stderr above
|
||||
# because the actual error raised is not helpful. in WSL 1 node.exe cannot handle
|
||||
# output redirection properly. See https://github.com/microsoft/WSL/issues/2370
|
||||
if [ "$IS_WSL" == "true" ]; then
|
||||
echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
|
||||
fi
|
||||
no_node_dir
|
||||
fi
|
||||
NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"
|
||||
NPX_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npx-cli.js"
|
||||
NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`
|
||||
if [ $? -ne 0 ]; then
|
||||
no_node_dir
|
||||
fi
|
||||
NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
|
||||
|
||||
# a path that will fail -f test on any posix bash
|
||||
NPX_WSL_PATH="/.."
|
||||
|
||||
# WSL can run Windows binaries, so we have to give it the win32 path
|
||||
# however, WSL bash tests against posix paths, so we need to construct that
|
||||
# to know if npm is installed globally.
|
||||
if [ "$IS_WSL" == "true" ]; then
|
||||
NPX_WSL_PATH=`wslpath "$NPM_PREFIX_NPX_CLI_JS"`
|
||||
fi
|
||||
if [ -f "$NPM_PREFIX_NPX_CLI_JS" ] || [ -f "$NPX_WSL_PATH" ]; then
|
||||
NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS"
|
||||
fi
|
||||
|
||||
"$NODE_EXE" "$NPX_CLI_JS" "$@"
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const cli = require('../lib/cli.js')
|
||||
|
||||
// run the resulting command as `npm exec ...args`
|
||||
process.argv[1] = require.resolve('./npm-cli.js')
|
||||
process.argv.splice(2, 0, 'exec')
|
||||
|
||||
// TODO: remove the affordances for removed items in npm v9
|
||||
const removedSwitches = new Set([
|
||||
'always-spawn',
|
||||
'ignore-existing',
|
||||
'shell-auto-fallback',
|
||||
])
|
||||
|
||||
const removedOpts = new Set([
|
||||
'npm',
|
||||
'node-arg',
|
||||
'n',
|
||||
])
|
||||
|
||||
const removed = new Set([
|
||||
...removedSwitches,
|
||||
...removedOpts,
|
||||
])
|
||||
|
||||
const { definitions, shorthands } = require('@npmcli/config/lib/definitions')
|
||||
const npmSwitches = Object.entries(definitions)
|
||||
.filter(([, { type }]) => type === Boolean ||
|
||||
(Array.isArray(type) && type.includes(Boolean)))
|
||||
.map(([key]) => key)
|
||||
|
||||
// things that don't take a value
|
||||
const switches = new Set([
|
||||
...removedSwitches,
|
||||
...npmSwitches,
|
||||
'no-install',
|
||||
'quiet',
|
||||
'q',
|
||||
'version',
|
||||
'v',
|
||||
'help',
|
||||
'h',
|
||||
])
|
||||
|
||||
// things that do take a value
|
||||
const opts = new Set([
|
||||
...removedOpts,
|
||||
'package',
|
||||
'p',
|
||||
'cache',
|
||||
'userconfig',
|
||||
'call',
|
||||
'c',
|
||||
'shell',
|
||||
'npm',
|
||||
'node-arg',
|
||||
'n',
|
||||
])
|
||||
|
||||
// break out of loop when we find a positional argument or --
|
||||
// If we find a positional arg, we shove -- in front of it, and
|
||||
// let the normal npm cli handle the rest.
|
||||
let i
|
||||
let sawRemovedFlags = false
|
||||
for (i = 3; i < process.argv.length; i++) {
|
||||
const arg = process.argv[i]
|
||||
if (arg === '--') {
|
||||
break
|
||||
} else if (/^-/.test(arg)) {
|
||||
const [key, ...v] = arg.replace(/^-+/, '').split('=')
|
||||
|
||||
switch (key) {
|
||||
case 'p':
|
||||
process.argv[i] = ['--package', ...v].join('=')
|
||||
break
|
||||
|
||||
case 'shell':
|
||||
process.argv[i] = ['--script-shell', ...v].join('=')
|
||||
break
|
||||
|
||||
case 'no-install':
|
||||
process.argv[i] = '--yes=false'
|
||||
break
|
||||
|
||||
default:
|
||||
// resolve shorthands and run again
|
||||
if (shorthands[key] && !removed.has(key)) {
|
||||
const a = [...shorthands[key]]
|
||||
if (v.length) {
|
||||
a.push(v.join('='))
|
||||
}
|
||||
process.argv.splice(i, 1, ...a)
|
||||
i--
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if (removed.has(key)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`npx: the --${key} argument has been removed.`)
|
||||
sawRemovedFlags = true
|
||||
process.argv.splice(i, 1)
|
||||
i--
|
||||
}
|
||||
|
||||
if (v.length === 0 && !switches.has(key) &&
|
||||
(opts.has(key) || !/^-/.test(process.argv[i + 1]))) {
|
||||
// value will be next argument, skip over it.
|
||||
if (removed.has(key)) {
|
||||
// also remove the value for the cut key.
|
||||
process.argv.splice(i + 1, 1)
|
||||
} else {
|
||||
i++
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// found a positional arg, put -- in front of it, and we're done
|
||||
process.argv.splice(i, 0, '--')
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (sawRemovedFlags) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('See `npm help exec` for more information')
|
||||
}
|
||||
|
||||
cli(process)
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
:: Created by npm, please don't edit manually.
|
||||
@ECHO OFF
|
||||
|
||||
SETLOCAL
|
||||
|
||||
SET "NODE_EXE=%~dp0\node.exe"
|
||||
IF NOT EXIST "%NODE_EXE%" (
|
||||
SET "NODE_EXE=node"
|
||||
)
|
||||
|
||||
SET "NPM_PREFIX_JS=%~dp0\node_modules\npm\bin\npm-prefix.js"
|
||||
SET "NPX_CLI_JS=%~dp0\node_modules\npm\bin\npx-cli.js"
|
||||
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (
|
||||
SET "NPM_PREFIX_NPX_CLI_JS=%%F\node_modules\npm\bin\npx-cli.js"
|
||||
)
|
||||
IF EXIST "%NPM_PREFIX_NPX_CLI_JS%" (
|
||||
SET "NPX_CLI_JS=%NPM_PREFIX_NPX_CLI_JS%"
|
||||
)
|
||||
|
||||
"%NODE_EXE%" "%NPX_CLI_JS%" %*
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
Set-StrictMode -Version 'Latest'
|
||||
|
||||
$NODE_EXE="$PSScriptRoot/node.exe"
|
||||
if (-not (Test-Path $NODE_EXE)) {
|
||||
$NODE_EXE="$PSScriptRoot/node"
|
||||
}
|
||||
if (-not (Test-Path $NODE_EXE)) {
|
||||
$NODE_EXE="node"
|
||||
}
|
||||
|
||||
$NPM_PREFIX_JS="$PSScriptRoot/node_modules/npm/bin/npm-prefix.js"
|
||||
$NPX_CLI_JS="$PSScriptRoot/node_modules/npm/bin/npx-cli.js"
|
||||
$NPM_PREFIX=(& $NODE_EXE $NPM_PREFIX_JS)
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Could not determine Node.js install directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
|
||||
if (Test-Path $NPM_PREFIX_NPX_CLI_JS) {
|
||||
$NPX_CLI_JS=$NPM_PREFIX_NPX_CLI_JS
|
||||
}
|
||||
|
||||
if ($MyInvocation.ExpectingInput) { # takes pipeline input
|
||||
$input | & $NODE_EXE $NPX_CLI_JS $args
|
||||
} elseif (-not $MyInvocation.Line) { # used "-File" argument
|
||||
& $NODE_EXE $NPX_CLI_JS $args
|
||||
} else { # used "-Command" argument
|
||||
if (($MyInvocation | Get-Member -Name 'Statement') -and $MyInvocation.Statement) {
|
||||
$NPX_ORIGINAL_COMMAND = $MyInvocation.Statement
|
||||
} else {
|
||||
$NPX_ORIGINAL_COMMAND = (
|
||||
[Management.Automation.InvocationInfo].GetProperty('ScriptPosition', [Reflection.BindingFlags] 'Instance, NonPublic')
|
||||
).GetValue($MyInvocation).Text
|
||||
}
|
||||
|
||||
$NODE_EXE = $NODE_EXE.Replace("``", "````")
|
||||
$NPX_CLI_JS = $NPX_CLI_JS.Replace("``", "````")
|
||||
|
||||
$NPX_COMMAND_ARRAY = [Management.Automation.Language.Parser]::ParseInput($NPX_ORIGINAL_COMMAND, [ref] $null, [ref] $null).
|
||||
EndBlock.Statements.PipelineElements.CommandElements.Extent.Text
|
||||
$NPX_ARGS = ($NPX_COMMAND_ARRAY | Select-Object -Skip 1) -join ' '
|
||||
|
||||
Invoke-Expression "& `"$NODE_EXE`" `"$NPX_CLI_JS`" $NPX_ARGS"
|
||||
}
|
||||
|
||||
exit $LASTEXITCODE
|
||||
Generated
Vendored
+95
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: npm-access
|
||||
section: 1
|
||||
description: Set access level on published packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm access list packages [<user>|<scope>|<scope:team>] [<package>]
|
||||
npm access list collaborators [<package> [<user>]]
|
||||
npm access get status [<package>]
|
||||
npm access set status=public|private [<package>]
|
||||
npm access set mfa=none|publish|automation [<package>]
|
||||
npm access grant <read-only|read-write> <scope:team> [<package>]
|
||||
npm access revoke <scope:team> [<package>]
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Used to set access controls on private packages.
|
||||
|
||||
For all of the subcommands, `npm access` will perform actions on the packages in the current working directory if no package name is passed to the subcommand.
|
||||
|
||||
* grant / revoke:
|
||||
Add or remove the ability of users and teams to have read-only or read-write access to a package.
|
||||
|
||||
### Details
|
||||
|
||||
`npm access` always operates directly on the current registry, configurable from the command line using `--registry=<registry url>`.
|
||||
|
||||
Unscoped packages are *always public*.
|
||||
|
||||
Scoped packages *default to restricted*, but you can either publish them as public using `npm publish --access=public`, or set their access as public using `npm access set status=public` after the initial publish.
|
||||
|
||||
You must have privileges to set the access of a package:
|
||||
|
||||
* You are an owner of an unscoped or scoped package.
|
||||
* You are a member of the team that owns a scope.
|
||||
* You have been given read-write privileges for a package, either as a member of a team or directly as an owner.
|
||||
|
||||
If you have two-factor authentication enabled then you'll be prompted to provide a second factor, or may use the `--otp=...` option to specify it on the command line.
|
||||
|
||||
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
|
||||
`--access=public`.
|
||||
|
||||
Management of teams and team memberships is done with the `npm team` command.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [`libnpmaccess`](https://npm.im/libnpmaccess)
|
||||
* [npm team](/commands/npm-team)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm registry](/using-npm/registry)
|
||||
Generated
Vendored
+87
@@ -0,0 +1,87 @@
|
||||
---
|
||||
title: npm-adduser
|
||||
section: 1
|
||||
description: Add a registry user account
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm adduser
|
||||
|
||||
alias: add-user
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Create a new user in the specified registry, and save the credentials to the `.npmrc` file.
|
||||
If no registry is specified, the default registry will be used (see [`registry`](/using-npm/registry)).
|
||||
|
||||
When you run `npm adduser`, the CLI automatically generates a legacy token of `publish` type.
|
||||
For more information, see [About legacy tokens](/about-access-tokens#about-legacy-tokens).
|
||||
|
||||
When using `legacy` for your `auth-type`, the username, password, and email are read in from prompts.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `scope`
|
||||
|
||||
* Default: the scope of the current project, if any, or ""
|
||||
* Type: String
|
||||
|
||||
Associate an operation with a scope for a scoped registry.
|
||||
|
||||
Useful when logging in to or out of a private registry:
|
||||
|
||||
```
|
||||
# log in, linking the scope to the custom registry
|
||||
npm login --scope=@mycorp --registry=https://registry.mycorp.com
|
||||
|
||||
# log out, removing the link and the auth token
|
||||
npm logout --scope=@mycorp
|
||||
```
|
||||
|
||||
This will cause `@mycorp` to be mapped to the registry for future
|
||||
installation of packages specified according to the pattern
|
||||
`@mycorp/package`.
|
||||
|
||||
This will also cause `npm init` to create a scoped package.
|
||||
|
||||
```
|
||||
# accept all defaults, and create a package named "@foo/whatever",
|
||||
# instead of just named "whatever"
|
||||
npm init --scope=@foo --yes
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### `auth-type`
|
||||
|
||||
* Default: "web"
|
||||
* Type: "legacy" or "web"
|
||||
|
||||
What authentication strategy to use with `login`. Note that if an `otp`
|
||||
config is given, this value will always be set to `legacy`.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm owner](/commands/npm-owner)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
* [npm token](/commands/npm-token)
|
||||
* [npm profile](/commands/npm-profile)
|
||||
Generated
Vendored
+125
@@ -0,0 +1,125 @@
|
||||
---
|
||||
title: npm-approve-scripts
|
||||
section: 1
|
||||
description: Approve install scripts for specific dependencies
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm approve-scripts <pkg> [<pkg> ...]
|
||||
npm approve-scripts --all
|
||||
npm approve-scripts --allow-scripts-pending
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Manages the `allowScripts` field in your project's `package.json`, which
|
||||
records which of your dependencies are permitted to run install scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
sources). This command is the recommended way to maintain that field.
|
||||
|
||||
In the current release, this field is advisory: install scripts still run
|
||||
by default, but installs print a list of packages whose scripts have not
|
||||
been reviewed. A future release will block unreviewed install scripts.
|
||||
|
||||
There are three modes:
|
||||
|
||||
```bash
|
||||
npm approve-scripts <pkg> [<pkg> ...]
|
||||
npm approve-scripts --all
|
||||
npm approve-scripts --allow-scripts-pending
|
||||
```
|
||||
|
||||
`<pkg>` matches every installed version of that package. By default the
|
||||
command writes pinned entries (`pkg@1.2.3`), which keep their approval
|
||||
narrowed to the specific version you reviewed. Pass `--no-allow-scripts-pin` to write
|
||||
name-only entries that allow any future version.
|
||||
|
||||
`--all` approves every package with unreviewed install scripts in one go.
|
||||
|
||||
`--allow-scripts-pending` is read-only: it lists every package whose install scripts
|
||||
are not yet covered by `allowScripts`, without modifying `package.json`.
|
||||
|
||||
`approve-scripts` honours the asymmetric pin rule: if you re-approve a
|
||||
package whose installed version has changed, the existing pin is rewritten
|
||||
to track the new installed version. Multi-version statements
|
||||
(`pkg@1 || 2`) are left alone, since they likely capture intent that
|
||||
the command cannot infer. Existing `false` entries always win;
|
||||
`approve-scripts` will not silently re-allow a package you previously
|
||||
denied.
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# Approve all currently-installed install scripts after reviewing them
|
||||
npm approve-scripts --all
|
||||
|
||||
# Approve specific packages, pinned to their installed version
|
||||
npm approve-scripts canvas sharp
|
||||
|
||||
# Approve name-only (any version of this package is allowed)
|
||||
npm approve-scripts --no-allow-scripts-pin canvas
|
||||
|
||||
# Preview which packages still need review
|
||||
npm approve-scripts --allow-scripts-pending
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `all`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When running `npm outdated` and `npm ls`, setting `--all` will show all
|
||||
outdated or installed packages, rather than only those directly depended
|
||||
upon by the current project.
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts-pending`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
List packages with install scripts that are not yet covered by the
|
||||
`allowScripts` policy, without modifying `package.json`. Only meaningful for
|
||||
`npm approve-scripts`.
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts-pin`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Write pinned (`pkg@version`) entries when approving install scripts. Set to
|
||||
`false` to write name-only entries that allow any version. Has no effect on
|
||||
`npm deny-scripts`, which always writes name-only entries regardless of this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm deny-scripts](/commands/npm-deny-scripts)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm rebuild](/commands/npm-rebuild)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
+449
@@ -0,0 +1,449 @@
|
||||
---
|
||||
title: npm-audit
|
||||
section: 1
|
||||
description: Run a security audit
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm audit [fix|signatures]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
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.
|
||||
If any vulnerabilities are found, then the impact and appropriate remediation will be calculated.
|
||||
If the `fix` argument is provided, then remediations will be applied to the package tree.
|
||||
|
||||
The command will exit with a 0 exit code if no vulnerabilities were found.
|
||||
|
||||
Note that some vulnerabilities cannot be fixed automatically and will require manual intervention or review.
|
||||
Also note that since `npm audit fix` runs a full-fledged `npm install` under the hood, all configs that apply to the installer will also apply to `npm install` -- so things like `npm audit fix --package-lock-only` will work as expected.
|
||||
|
||||
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 `--audit-level` 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.
|
||||
|
||||
### Package lock
|
||||
|
||||
By default npm requires a package-lock or shrinkwrap in order to run the audit.
|
||||
You can bypass the package lock with `--no-package-lock` but be aware the results may be different with every run, since npm will re-build the dependency tree each time.
|
||||
|
||||
### Audit Signatures
|
||||
|
||||
To ensure the integrity of packages you download from the public npm registry, or any registry that supports signatures, you can verify the registry signatures of downloaded packages using the npm CLI.
|
||||
|
||||
Registry signatures can be verified using the following `audit` command:
|
||||
|
||||
```bash
|
||||
$ npm audit signatures
|
||||
```
|
||||
|
||||
The `audit signatures` command will also verify the provenance attestations of downloaded packages.
|
||||
Because provenance attestations are such a new feature, security features may be added to (or changed in) the attestation format over time.
|
||||
To ensure that you're always able to verify attestation signatures check that you're running the latest version of the npm CLI. Please note this often means updating npm beyond the version that ships with Node.js.
|
||||
|
||||
To include the full sigstore attestation bundles in JSON output, use:
|
||||
|
||||
```bash
|
||||
$ npm audit signatures --json --include-attestations
|
||||
```
|
||||
|
||||
This adds a `verified` array to the JSON output containing the attestation
|
||||
bundles (DSSE envelopes, verification material, and transparency log entries)
|
||||
for each verified package.
|
||||
|
||||
The npm CLI supports registry signatures and signing keys provided by any registry if the following conventions are followed:
|
||||
|
||||
1. Signatures are provided in the package's `packument` in each published version within the `dist` object:
|
||||
|
||||
```json
|
||||
"dist":{
|
||||
"..omitted..": "..omitted..",
|
||||
"signatures": [{
|
||||
"keyid": "SHA256:{{SHA256_PUBLIC_KEY}}",
|
||||
"sig": "a312b9c3cb4a1b693e8ebac5ee1ca9cc01f2661c14391917dcb111517f72370809..."
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
See this [example](https://registry.npmjs.org/light-cycle/1.4.3) of a signed package from the public npm registry.
|
||||
|
||||
The `sig` is generated using the following template: `${package.name}@${package.version}:${package.dist.integrity}` and the `keyid` has to match one of the public signing keys below.
|
||||
|
||||
2. Public signing keys are provided at `registry-host.tld/-/npm/v1/keys` in the following format:
|
||||
|
||||
```
|
||||
{
|
||||
"keys": [{
|
||||
"expires": null,
|
||||
"keyid": "SHA256:{{SHA256_PUBLIC_KEY}}",
|
||||
"keytype": "ecdsa-sha2-nistp256",
|
||||
"scheme": "ecdsa-sha2-nistp256",
|
||||
"key": "{{B64_PUBLIC_KEY}}"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
Keys response:
|
||||
|
||||
- `expires`: null or a simplified extended [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDTHH:mm:ss.sssZ`
|
||||
- `keyid`: sha256 fingerprint of the public key
|
||||
- `keytype`: only `ecdsa-sha2-nistp256` is currently supported by the npm CLI
|
||||
- `scheme`: only `ecdsa-sha2-nistp256` is currently supported by the npm CLI
|
||||
- `key`: base64 encoded public key
|
||||
|
||||
See this [example key's response from the public npm registry](https://registry.npmjs.org/-/npm/v1/keys).
|
||||
|
||||
### Audit Endpoints
|
||||
|
||||
There are two audit endpoints that npm may use to fetch vulnerability information: the `Bulk Advisory` endpoint and the `Quick Audit` endpoint.
|
||||
|
||||
#### Bulk Advisory Endpoint
|
||||
|
||||
As of version 7, npm uses the much faster `Bulk Advisory` endpoint to optimize the speed of calculating audit results.
|
||||
|
||||
npm will generate a JSON payload with the name and list of versions of each package in the tree, and POST it to the default configured registry at the path `/-/npm/v1/security/advisories/bulk`.
|
||||
|
||||
Any packages in the tree that do not have a `version` field in their package.json file will be ignored.
|
||||
If any `--omit` options are specified (either via the [`--omit` config](/using-npm/config#omit), or one of the shorthands such as `--production`, `--only=dev`, and so on), then packages will be omitted from the submitted payload as appropriate.
|
||||
|
||||
If the registry responds with an error, or with an invalid response, then npm will attempt to load advisory data from the `Quick Audit` endpoint.
|
||||
|
||||
The expected result will contain a set of advisory objects for each dependency that matches the advisory range.
|
||||
Each advisory object contains a `name`, `url`, `id`, `severity`, `vulnerable_versions`, and `title`.
|
||||
|
||||
npm then uses these advisory objects to calculate vulnerabilities and meta-vulnerabilities of the dependencies within the tree.
|
||||
|
||||
#### Quick Audit Endpoint
|
||||
|
||||
If the `Bulk Advisory` endpoint returns an error, or invalid data, npm will attempt to load advisory data from the `Quick Audit` endpoint, which is considerably slower in most cases.
|
||||
|
||||
The full package tree as found in `package-lock.json` is submitted, along with the following pieces of additional metadata:
|
||||
|
||||
* `npm_version`
|
||||
* `node_version`
|
||||
* `platform`
|
||||
* `arch`
|
||||
* `node_env`
|
||||
|
||||
All packages in the tree are submitted to the Quick Audit endpoint.
|
||||
Omitted dependency types are skipped when generating the report.
|
||||
|
||||
#### Scrubbing
|
||||
|
||||
Out of an abundance of caution, npm versions 5 and 6 would "scrub" any packages from the submitted report if their name contained a `/` character, so as to avoid leaking the names of potentially private packages or git URLs.
|
||||
|
||||
However, in practice, this resulted in audits often failing to properly detect meta-vulnerabilities, because the tree would appear to be invalid due to missing dependencies, and prevented the detection of vulnerabilities in package trees that used git dependencies or private modules.
|
||||
|
||||
This scrubbing has been removed from npm as of version 7.
|
||||
|
||||
#### Calculating Meta-Vulnerabilities and Remediations
|
||||
|
||||
npm uses the [`@npmcli/metavuln-calculator`](http://npm.im/@npmcli/metavuln-calculator) module to turn a set of security advisories into a set of "vulnerability" objects.
|
||||
A "meta-vulnerability" is a dependency that is vulnerable by virtue of dependence on vulnerable versions of a vulnerable package.
|
||||
|
||||
For example, if the package `foo` is vulnerable in the range `>=1.0.2 <2.0.0`, and the package `bar` depends on `foo@^1.1.0`, then that version of `bar` can only be installed by installing a vulnerable version of `foo`.
|
||||
In this case, `bar` is a "metavulnerability".
|
||||
|
||||
Once metavulnerabilities for a given package are calculated, they are cached in the `~/.npm` folder and only re-evaluated if the advisory range changes, or a new version of the package is published (in which case, the new version is checked for metavulnerable status as well).
|
||||
|
||||
If the chain of metavulnerabilities extends all the way to the root project, and it cannot be updated without changing its dependency ranges, then `npm audit fix` will require the `--force` option to apply the remediation.
|
||||
If remediations do not require changes to the dependency ranges, then all vulnerable packages will be updated to a version that does not have an advisory or metavulnerability posted against it.
|
||||
|
||||
### Exit Code
|
||||
|
||||
The `npm audit` command will exit with a 0 exit code if no vulnerabilities were found.
|
||||
The `npm audit fix` command will exit with 0 exit code if no vulnerabilities are found _or_ if the remediation is able to successfully fix all vulnerabilities.
|
||||
|
||||
If vulnerabilities were found the exit code will depend on the [`audit-level` config](/using-npm/config#audit-level).
|
||||
|
||||
### Examples
|
||||
|
||||
Scan your project for vulnerabilities and automatically install any compatible updates to vulnerable dependencies:
|
||||
|
||||
```bash
|
||||
$ npm audit fix
|
||||
```
|
||||
|
||||
Run `audit fix` without modifying `node_modules`, but still updating the pkglock:
|
||||
|
||||
```bash
|
||||
$ npm audit fix --package-lock-only
|
||||
```
|
||||
|
||||
Skip updating `devDependencies`:
|
||||
|
||||
```bash
|
||||
$ npm audit fix --only=prod
|
||||
```
|
||||
|
||||
Have `audit fix` install SemVer-major updates to toplevel dependencies, not just SemVer-compatible ones:
|
||||
|
||||
```bash
|
||||
$ npm audit fix --force
|
||||
```
|
||||
|
||||
Do a dry run to get an idea of what `audit fix` will do, and _also_ output install information in JSON format:
|
||||
|
||||
```bash
|
||||
$ npm audit fix --dry-run --json
|
||||
```
|
||||
|
||||
Scan your project for vulnerabilities and just show the details, without fixing anything:
|
||||
|
||||
```bash
|
||||
$ npm audit
|
||||
```
|
||||
|
||||
Get the detailed audit report in JSON format:
|
||||
|
||||
```bash
|
||||
$ npm audit --json
|
||||
```
|
||||
|
||||
Fail an audit only if the results include a vulnerability with a level of moderate or higher:
|
||||
|
||||
```bash
|
||||
$ npm audit --audit-level=moderate
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `audit-level`
|
||||
|
||||
* Default: null
|
||||
* Type: null, "info", "low", "moderate", "high", "critical", or "none"
|
||||
|
||||
The minimum level of vulnerability for `npm audit` to exit with a non-zero
|
||||
exit code.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `force`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Removes various protections against unfortunate side effects, common
|
||||
mistakes, unnecessary performance degradation, and malicious input.
|
||||
|
||||
* Allow clobbering non-npm files in global installs.
|
||||
* Allow the `npm version` command to work on an unclean git repository.
|
||||
* Allow deleting the cache folder with `npm cache clean`.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of npm.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of `node`, even if `--engine-strict` is enabled.
|
||||
* Allow `npm audit fix` to install modules outside your stated dependency
|
||||
range (including SemVer-major changes).
|
||||
* Allow unpublishing all versions of a published package.
|
||||
* Allow conflicting peerDependencies to be installed in the root project.
|
||||
* Implicitly set `--yes` during `npm init`.
|
||||
* Allow clobbering existing values in `npm pkg`
|
||||
* Allow unpublishing of entire packages (not just a single version).
|
||||
|
||||
If you don't have a clear idea of what you want to do, it is strongly
|
||||
recommended that you do not use this option!
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `package-lock-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the current operation will only use the `package-lock.json`,
|
||||
ignoring `node_modules`.
|
||||
|
||||
For `update` this means only the `package-lock.json` will be updated,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
For `list` this means the output will be based on the tree described by the
|
||||
`package-lock.json`, rather than the contents of `node_modules`.
|
||||
|
||||
|
||||
|
||||
#### `package-lock`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to false, then ignore `package-lock.json` files when installing. This
|
||||
will also prevent _writing_ `package-lock.json` if `save` is true.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `include-attestations`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When used with `npm audit signatures --json`, includes the full sigstore
|
||||
attestation bundles in the JSON output for each verified package. The
|
||||
bundles contain DSSE envelopes, verification material, and transparency log
|
||||
entries.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/commands/npm-install)
|
||||
* [config](/using-npm/config)
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
---
|
||||
title: npm-bugs
|
||||
section: 1
|
||||
description: Report bugs for a package in a web browser
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm bugs [<pkgname> [<pkgname> ...]]
|
||||
|
||||
alias: issues
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command tries to guess at the likely location of a package's bug tracker URL or the `mailto` URL of the support email, and then tries to open it using the [`--browser` config](/using-npm/config#browser) param.
|
||||
If no package name is provided, it will search for a `package.json` in the current folder and use the `name` property.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `browser`
|
||||
|
||||
* Default: macOS: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
|
||||
* Type: null, Boolean, or String
|
||||
|
||||
The browser that is called by npm commands to open websites.
|
||||
|
||||
Set to `false` to suppress browser behavior and instead print urls to
|
||||
terminal.
|
||||
|
||||
Set to `true` to use default system URL opener.
|
||||
|
||||
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm docs](/commands/npm-docs)
|
||||
* [npm view](/commands/npm-view)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
---
|
||||
title: npm-cache
|
||||
section: 1
|
||||
description: Manipulates packages cache
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm cache add <package-spec>
|
||||
npm cache clean [<key>]
|
||||
npm cache ls [<name>@<version>]
|
||||
npm cache verify
|
||||
npm cache npx ls
|
||||
npm cache npx rm [<key>...]
|
||||
npm cache npx info <key>...
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Used to add, list, or clean the `npm cache` folder.
|
||||
Also used to view info about entries in the `npm exec` (aka `npx`) cache folder.
|
||||
|
||||
#### `npm cache`
|
||||
|
||||
* add:
|
||||
Add the specified packages 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.
|
||||
|
||||
* clean:
|
||||
Delete a single entry or all entries out of the cache folder.
|
||||
Note that this is typically unnecessary, as npm's cache is self-healing and resistant to data corruption issues.
|
||||
|
||||
* ls:
|
||||
List given entries or all entries in the local cache.
|
||||
|
||||
* 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.
|
||||
|
||||
#### `npm cache npx`
|
||||
|
||||
* ls:
|
||||
List all entries in the npx cache.
|
||||
|
||||
* rm:
|
||||
Remove given entries or all entries from the npx cache.
|
||||
|
||||
* info:
|
||||
Get detailed information about given entries in the npx cache.
|
||||
|
||||
### Details
|
||||
|
||||
npm stores cache data in an opaque directory within the configured `cache`, named `_cacache`.
|
||||
This directory is a [`cacache`](http://npm.im/cacache)-based content-addressable cache that stores all http request data as well as other package-related data.
|
||||
This directory is primarily accessed through `pacote`, the library responsible for all package fetching as of npm@5.
|
||||
|
||||
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 `pacote` 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 `clean` now requires `--force` to run.
|
||||
|
||||
There is currently no method exposed through npm to inspect or directly manage the contents of this cache.
|
||||
In order to access it, `cacache` must be used directly.
|
||||
|
||||
npm will not remove data by itself: the cache will grow as new packages are installed.
|
||||
|
||||
### A note about the cache's design
|
||||
|
||||
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.
|
||||
|
||||
To run an offline verification of existing cache contents, use `npm cache verify`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `cache`
|
||||
|
||||
* Default: Windows: `%LocalAppData%\npm-cache`, Posix: `~/.npm`
|
||||
* Type: Path
|
||||
|
||||
The location of npm's cache directory.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm pack](/commands/npm-pack)
|
||||
* [npm exec](/commands/npm-exec)
|
||||
* https://npm.im/cacache
|
||||
* https://npm.im/pacote
|
||||
* https://npm.im/@npmcli/arborist
|
||||
* https://npm.im/make-fetch-happen
|
||||
+434
@@ -0,0 +1,434 @@
|
||||
---
|
||||
title: npm-ci
|
||||
section: 1
|
||||
description: Clean install a project
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
|
||||
aliases: clean-install, ic, install-clean, isntall-clean
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command is similar to [`npm install`](/commands/npm-install), 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.
|
||||
|
||||
The main differences between using `npm install` and `npm ci` are:
|
||||
|
||||
* The project **must** have an existing `package-lock.json` or
|
||||
`npm-shrinkwrap.json`.
|
||||
* If dependencies in the package lock do not match those in `package.json`,
|
||||
`npm ci` will exit with an error, instead of updating the package lock.
|
||||
* `npm ci` can only install entire projects at a time: individual dependencies cannot be added with this command.
|
||||
* If a `node_modules` is already present, it will be automatically removed before `npm ci` begins its install.
|
||||
* It will never write to `package.json` or any of the package-locks:
|
||||
installs are essentially frozen.
|
||||
|
||||
NOTE: If you create your `package-lock.json` file by running `npm install` with flags that can affect the shape of your dependency tree, such as
|
||||
`--legacy-peer-deps` or `--install-links`, you _must_ provide the same flags to `npm ci` or you are likely to encounter errors.
|
||||
An easy way to do this is to run, for example,
|
||||
`npm config set legacy-peer-deps=true --location=project` and commit the
|
||||
`.npmrc` file to your repo.
|
||||
|
||||
### Example
|
||||
|
||||
Make sure you have a package-lock and an up-to-date install:
|
||||
|
||||
```bash
|
||||
$ cd ./my/npm/project
|
||||
$ npm install
|
||||
added 154 packages in 10s
|
||||
$ ls | grep package-lock
|
||||
```
|
||||
|
||||
Run `npm ci` in that project
|
||||
|
||||
```bash
|
||||
$ npm ci
|
||||
added 154 packages in 5s
|
||||
```
|
||||
|
||||
Configure Travis CI to build using `npm ci` instead of `npm install`:
|
||||
|
||||
```bash
|
||||
# .travis.yml
|
||||
install:
|
||||
- npm ci
|
||||
# keep the npm cache around to speed up installs
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.npm"
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-directory`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from directories. That
|
||||
is, dependencies that point to a directory instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any directories to be installed. `none` prevents any
|
||||
directories from being installed. `root` only allows directories defined in
|
||||
your project's package.json to be installed. Also allows directory
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-file`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from tarball files. That
|
||||
is, dependencies that point to a local tarball file instead of a version or
|
||||
semver range. Please note that this could leave your tree incomplete and
|
||||
some packages may not function as intended or designed. Changing this
|
||||
setting will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any tarball file to be installed. `none` prevents any tarball
|
||||
file from being installed. `root` only allows tarball files defined in your
|
||||
project's package.json to be installed. Also allows tarball file
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-git`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from git references. That
|
||||
is, dependencies that point to a git repo instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any git dependencies to be fetched and installed. `none`
|
||||
prevents any git dependencies from being fetched and installed. `root` only
|
||||
allows git dependencies defined in your project's package.json to be fetched
|
||||
and installed. Also allows git dependencies to be fetched for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-remote`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from urls. That is,
|
||||
dependencies that point to a tarball url instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any url to be installed. `none` prevents any url from being
|
||||
installed. `root` only allows urls defined in your project's package.json to
|
||||
be installed. Also allows url dependencies to be used for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Comma-separated list of packages whose install-time lifecycle scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
dependencies) are allowed to run.
|
||||
|
||||
This setting is intended for one-off and global contexts: `npm exec`, `npx`,
|
||||
and `npm install -g`, where no project `package.json` is involved. For
|
||||
team-wide policy in a project, use the `allowScripts` field in
|
||||
`package.json` (which also supports explicit denials), or configure it in
|
||||
`.npmrc`. Passing `--allow-scripts` on the command line during a
|
||||
project-scoped `npm install`, `ci`, `update`, or `rebuild` is an error.
|
||||
|
||||
Each name is matched against a dependency's resolved identity, not against
|
||||
the package's self-reported name. `--ignore-scripts` and
|
||||
`--dangerously-allow-all-scripts` both override this setting.
|
||||
|
||||
|
||||
|
||||
#### `strict-allow-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, turn the install-script policy from a warning into a hard error:
|
||||
any dependency with install scripts not covered by `allowScripts` will fail
|
||||
the install instead of running with a notice.
|
||||
|
||||
Dependencies explicitly denied with `false` in `allowScripts` are always
|
||||
silently skipped; this setting only affects unreviewed entries.
|
||||
`--ignore-scripts` and `--dangerously-allow-all-scripts` both override this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `dangerously-allow-all-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, bypass the `allowScripts` policy entirely and run every
|
||||
dependency install script regardless of whether it was approved or denied.
|
||||
Intended as a migration escape hatch only; its use is strongly discouraged.
|
||||
`--ignore-scripts` still takes precedence over this setting.
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/commands/npm-install)
|
||||
* [package-lock.json](/configuring-npm/package-lock-json)
|
||||
Generated
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: npm-completion
|
||||
section: 1
|
||||
description: Tab Completion for npm
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm completion
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Enables tab-completion in all npm commands.
|
||||
|
||||
The synopsis above loads the completions into your current shell.
|
||||
Adding it to your ~/.bashrc or ~/.zshrc will make the completions available everywhere:
|
||||
|
||||
```bash
|
||||
npm completion >> ~/.bashrc
|
||||
npm completion >> ~/.zshrc
|
||||
```
|
||||
|
||||
You may of course also pipe the output of `npm completion` to a file such as `/usr/local/etc/bash_completion.d/npm` or
|
||||
`/etc/bash_completion.d/npm` if you have a system that will read
|
||||
that file for you.
|
||||
|
||||
When `COMP_CWORD`, `COMP_LINE`, and `COMP_POINT` are defined in the environment, `npm completion` acts in "plumbing mode", and outputs completions based on the arguments.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm developers](/using-npm/developers)
|
||||
* [npm](/commands/npm)
|
||||
Generated
Vendored
+176
@@ -0,0 +1,176 @@
|
||||
---
|
||||
title: npm-config
|
||||
section: 1
|
||||
description: Manage the npm configuration files
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm config set <key>=<value> [<key>=<value> ...]
|
||||
npm config get [<key> [<key> ...]]
|
||||
npm config delete <key> [<key> ...]
|
||||
npm config list [--json]
|
||||
npm config edit
|
||||
npm config fix
|
||||
|
||||
alias: c
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
npm gets its config settings from the command line, environment variables, `npmrc` files, and in some cases, the `package.json` file.
|
||||
|
||||
See [npmrc](/configuring-npm/npmrc) for more information about the npmrc files.
|
||||
|
||||
See [config](/using-npm/config) for a more thorough explanation of the mechanisms involved, and a full list of config options available.
|
||||
|
||||
The `npm config` command can be used to update and edit the contents of the user and global npmrc files.
|
||||
|
||||
### Sub-commands
|
||||
|
||||
Config supports the following sub-commands:
|
||||
|
||||
#### set
|
||||
|
||||
```bash
|
||||
npm config set key=value [key=value...]
|
||||
npm set key=value [key=value...]
|
||||
```
|
||||
|
||||
Sets each of the config keys to the value provided.
|
||||
Modifies the user configuration file unless [`location`](/commands/npm-config#location) is passed.
|
||||
|
||||
If value is omitted, the key will be removed from your config file entirely.
|
||||
|
||||
Note: for backwards compatibility, `npm config set key value` is supported as an alias for `npm config set key=value`.
|
||||
|
||||
#### get
|
||||
|
||||
```bash
|
||||
npm config get [key ...]
|
||||
npm get [key ...]
|
||||
```
|
||||
|
||||
Echo the config value(s) to stdout.
|
||||
|
||||
If multiple keys are provided, then the values will be prefixed with the key names.
|
||||
|
||||
If no keys are provided, then this command behaves the same as `npm config list`.
|
||||
|
||||
#### list
|
||||
|
||||
```bash
|
||||
npm config list
|
||||
```
|
||||
|
||||
Show all the config settings.
|
||||
Use `-l` to also show defaults.
|
||||
Use `--json` to show the settings in json format.
|
||||
|
||||
#### delete
|
||||
|
||||
```bash
|
||||
npm config delete key [key ...]
|
||||
```
|
||||
|
||||
Deletes the specified keys from all configuration files.
|
||||
|
||||
#### edit
|
||||
|
||||
```bash
|
||||
npm config edit
|
||||
```
|
||||
|
||||
Opens the config file in an editor.
|
||||
Use the `--global` flag to edit the global config.
|
||||
|
||||
#### fix
|
||||
|
||||
```bash
|
||||
npm config fix
|
||||
```
|
||||
|
||||
Attempts to repair invalid configuration items.
|
||||
Usually this means attaching authentication config (i.e.
|
||||
`_auth`, `_authToken`) to the configured `registry`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `editor`
|
||||
|
||||
* Default: The EDITOR or VISUAL environment variables, or
|
||||
'%SYSTEMROOT%\notepad.exe' on Windows, or 'vi' on Unix systems
|
||||
* Type: String
|
||||
|
||||
The command to run for `npm edit` and `npm config edit`.
|
||||
|
||||
|
||||
|
||||
#### `location`
|
||||
|
||||
* Default: "user" unless `--global` is passed, which will also set this value
|
||||
to "global"
|
||||
* Type: "global", "user", or "project"
|
||||
|
||||
When passed to `npm config` this refers to which config file to use.
|
||||
|
||||
When set to "global" mode, packages are installed into the `prefix` folder
|
||||
instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `long`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show extended information in `ls`, `search`, and `help-search`.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm](/commands/npm)
|
||||
Generated
Vendored
+381
@@ -0,0 +1,381 @@
|
||||
---
|
||||
title: npm-dedupe
|
||||
section: 1
|
||||
description: Reduce duplication in the package tree
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm dedupe
|
||||
|
||||
alias: ddp
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
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.
|
||||
|
||||
For example, consider this dependency graph:
|
||||
|
||||
```
|
||||
a
|
||||
+-- b <-- depends on c@1.0.x
|
||||
| `-- c@1.0.3
|
||||
`-- d <-- depends on c@~1.0.9
|
||||
`-- c@1.0.10
|
||||
```
|
||||
|
||||
In this case, `npm dedupe` will transform the tree to:
|
||||
|
||||
```bash
|
||||
a
|
||||
+-- b
|
||||
+-- d
|
||||
`-- c@1.0.10
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
In some cases, you may have a dependency graph like this:
|
||||
|
||||
```
|
||||
a
|
||||
+-- b <-- depends on c@1.0.x
|
||||
+-- c@1.0.3
|
||||
`-- d <-- depends on c@1.x
|
||||
`-- c@1.9.9
|
||||
```
|
||||
|
||||
During the installation process, the `c@1.0.3` dependency for `b` was placed in the root of the tree.
|
||||
Though `d`'s dependency on `c@1.x` could have been satisfied by `c@1.0.3`, the newer `c@1.9.9` dependency was used, because npm favors updates by default, even when doing so causes duplication.
|
||||
|
||||
Running `npm dedupe` will cause npm to note the duplication and re-evaluate, deleting the nested `c` module, because the one in the root is sufficient.
|
||||
|
||||
To prefer deduplication over novelty during the installation process, run `npm install --prefer-dedupe` or `npm config set prefer-dedupe true`.
|
||||
|
||||
Arguments are ignored.
|
||||
Dedupe always acts on the entire tree.
|
||||
|
||||
Note that this operation transforms the dependency tree, but will never result in new modules being installed.
|
||||
|
||||
Using `npm find-dupes` will run the command in `--dry-run` mode.
|
||||
|
||||
Note: `npm dedupe` will never update the semver values of direct dependencies in your project `package.json`, if you want to update values in `package.json` you can run: `npm update --save` instead.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `package-lock`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to false, then ignore `package-lock.json` files when installing. This
|
||||
will also prevent _writing_ `package-lock.json` if `save` is true.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-directory`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from directories. That
|
||||
is, dependencies that point to a directory instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any directories to be installed. `none` prevents any
|
||||
directories from being installed. `root` only allows directories defined in
|
||||
your project's package.json to be installed. Also allows directory
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-file`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from tarball files. That
|
||||
is, dependencies that point to a local tarball file instead of a version or
|
||||
semver range. Please note that this could leave your tree incomplete and
|
||||
some packages may not function as intended or designed. Changing this
|
||||
setting will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any tarball file to be installed. `none` prevents any tarball
|
||||
file from being installed. `root` only allows tarball files defined in your
|
||||
project's package.json to be installed. Also allows tarball file
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-git`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from git references. That
|
||||
is, dependencies that point to a git repo instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any git dependencies to be fetched and installed. `none`
|
||||
prevents any git dependencies from being fetched and installed. `root` only
|
||||
allows git dependencies defined in your project's package.json to be fetched
|
||||
and installed. Also allows git dependencies to be fetched for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-remote`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from urls. That is,
|
||||
dependencies that point to a tarball url instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any url to be installed. `none` prevents any url from being
|
||||
installed. `root` only allows urls defined in your project's package.json to
|
||||
be installed. Also allows url dependencies to be used for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm find-dupes](/commands/npm-find-dupes)
|
||||
* [npm ls](/commands/npm-ls)
|
||||
* [npm update](/commands/npm-update)
|
||||
* [npm install](/commands/npm-install)
|
||||
Generated
Vendored
+109
@@ -0,0 +1,109 @@
|
||||
---
|
||||
title: npm-deny-scripts
|
||||
section: 1
|
||||
description: Deny install scripts for specific dependencies
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm deny-scripts <pkg> [<pkg> ...]
|
||||
npm deny-scripts --all
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
The companion command to [`npm approve-scripts`](/commands/npm-approve-scripts).
|
||||
Writes `false` entries into the `allowScripts` field of your project's
|
||||
`package.json`, recording that a dependency must not run install scripts
|
||||
even if a future version would otherwise be eligible.
|
||||
|
||||
In the current release, install scripts still run by default, so `deny-scripts`
|
||||
only affects how installs of denied packages are reported. A future release
|
||||
will block unreviewed install scripts and respect deny entries at install
|
||||
time.
|
||||
|
||||
```bash
|
||||
npm deny-scripts <pkg> [<pkg> ...]
|
||||
npm deny-scripts --all
|
||||
```
|
||||
|
||||
`<pkg>` matches every installed version of that package. Denies are always
|
||||
written name-only (`"pkg": false`), regardless of `--allow-scripts-pin`. Pinning a deny
|
||||
to a specific version would silently re-allow scripts for any other version
|
||||
of the same package, which defeats the purpose; the command picks the
|
||||
safer default for you.
|
||||
|
||||
`--all` denies every package with unreviewed install scripts.
|
||||
|
||||
If a `true` (pinned or name-only) entry exists for a package and you then
|
||||
deny it, the existing allow entries are removed so the name-only deny is
|
||||
unambiguous.
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# Deny a specific package outright
|
||||
npm deny-scripts telemetry-pkg
|
||||
|
||||
# Deny everything that has install scripts and isn't already approved
|
||||
npm deny-scripts --all
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `all`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When running `npm outdated` and `npm ls`, setting `--all` will show all
|
||||
outdated or installed packages, rather than only those directly depended
|
||||
upon by the current project.
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts-pending`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
List packages with install scripts that are not yet covered by the
|
||||
`allowScripts` policy, without modifying `package.json`. Only meaningful for
|
||||
`npm approve-scripts`.
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts-pin`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Write pinned (`pkg@version`) entries when approving install scripts. Set to
|
||||
`false` to write name-only entries that allow any version. Has no effect on
|
||||
`npm deny-scripts`, which always writes name-only entries regardless of this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm approve-scripts](/commands/npm-approve-scripts)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
Generated
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
---
|
||||
title: npm-deprecate
|
||||
section: 1
|
||||
description: Deprecate a version of a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm deprecate <package-spec> <message>
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
This command will update the npm registry entry for a package, providing a deprecation warning to all who attempt to install it.
|
||||
|
||||
It works on [version ranges](https://semver.npmjs.com/) as well as specific versions, so you can do something like this:
|
||||
|
||||
```bash
|
||||
npm deprecate my-thing@"< 0.2.3" "critical bug fixed in v0.2.3"
|
||||
```
|
||||
|
||||
SemVer ranges passed to this command are interpreted such that they *do* include prerelease versions.
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npm deprecate my-thing@1.x "1.x is no longer supported"
|
||||
```
|
||||
|
||||
In this case, a version `my-thing@1.0.0-beta.0` will also be deprecated.
|
||||
|
||||
You must be the package owner to deprecate something.
|
||||
See the `owner` and `adduser` help topics.
|
||||
|
||||
To un-deprecate a package, specify an empty string (`""`) for the `message` argument.
|
||||
Note that you must use double quotes with no space between them to format an empty string.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm owner](/commands/npm-owner)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
---
|
||||
title: npm-diff
|
||||
section: 1
|
||||
description: The registry diff command
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm diff [...<paths>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Similar to its `git diff` counterpart, this command will print diff patches of files for packages published to the npm registry.
|
||||
|
||||
* `npm diff --diff=<spec-a> --diff=<spec-b>`
|
||||
|
||||
Compares two package versions using their registry specifiers, e.g: `npm diff --diff=pkg@1.0.0 --diff=pkg@^2.0.0`.
|
||||
It's also possible to compare across forks of any package, e.g: `npm diff --diff=pkg@1.0.0 --diff=pkg-fork@1.0.0`.
|
||||
|
||||
Any valid spec can be used, so that it's also possible to compare directories or git repositories, e.g: `npm diff --diff=pkg@latest --diff=./packages/pkg`
|
||||
|
||||
Here's an example comparing two different versions of a package named `abbrev` from the registry:
|
||||
|
||||
```bash
|
||||
npm diff --diff=abbrev@1.1.0 --diff=abbrev@1.1.1
|
||||
```
|
||||
|
||||
On success, output looks like:
|
||||
|
||||
```bash
|
||||
diff --git a/package.json b/package.json
|
||||
index v1.1.0..v1.1.1 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "abbrev",
|
||||
- "version": "1.1.0",
|
||||
+ "version": "1.1.1",
|
||||
"description": "Like ruby's abbrev module, but in js",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me>",
|
||||
"main": "abbrev.js",
|
||||
```
|
||||
|
||||
Given the flexible nature of npm specs, you can also target local directories or git repos just like when using `npm install`:
|
||||
|
||||
```bash
|
||||
npm diff --diff=https://github.com/npm/libnpmdiff --diff=./local-path
|
||||
```
|
||||
|
||||
In the example above we can compare the contents from the package installed from the git repo at `github.com/npm/libnpmdiff` with the contents of the `./local-path` that contains a valid package, such as a modified copy of the original.
|
||||
|
||||
* `npm diff` (in a package directory, no arguments):
|
||||
|
||||
If the package is published to the registry, `npm diff` will fetch the tarball version tagged as `latest` (this value can be configured using the `tag` option) and proceed to compare the contents of files present in that tarball, with the current files in your local file system.
|
||||
|
||||
This workflow provides a handy way for package authors to see what package-tracked files have been changed in comparison with the latest published version of that package.
|
||||
|
||||
* `npm diff --diff=<pkg-name>` (in a package directory):
|
||||
|
||||
When using a single package name (with no version or tag specifier) as an argument, `npm diff` will work in a similar way to [`npm-outdated`](npm-outdated) and reach for the registry to figure out what current published version of the package named `<pkg-name>` will satisfy its dependent declared semver-range.
|
||||
Once that specific version is known `npm diff` will print diff patches comparing the current version of `<pkg-name>` found in the local file system with that specific version returned by the registry.
|
||||
|
||||
Given a package named `abbrev` that is currently installed:
|
||||
|
||||
```bash
|
||||
npm diff --diff=abbrev
|
||||
```
|
||||
|
||||
That will request from the registry its most up to date version and will print a diff output comparing the currently installed version to this newer one if the version numbers are not the same.
|
||||
|
||||
* `npm diff --diff=<spec-a>` (in a package directory):
|
||||
|
||||
Similar to using only a single package name, it's also possible to declare a full registry specifier version if you wish to compare the local version of an installed package with the specific version/tag/semver-range provided in `<spec-a>`.
|
||||
|
||||
An example: assuming `pkg@1.0.0` is installed in the current `node_modules` folder, running:
|
||||
|
||||
```bash
|
||||
npm diff --diff=pkg@2.0.0
|
||||
```
|
||||
|
||||
It will effectively be an alias to
|
||||
`npm diff --diff=pkg@1.0.0 --diff=pkg@2.0.0`.
|
||||
|
||||
* `npm diff --diff=<semver-a> [--diff=<semver-b>]` (in a package directory):
|
||||
|
||||
Using `npm diff` along with semver-valid version numbers is a shorthand to compare different versions of the current package.
|
||||
|
||||
It needs to be run from a package directory, such that for a package named `pkg` running `npm diff --diff=1.0.0 --diff=1.0.1` is the same as running `npm diff --diff=pkg@1.0.0 --diff=pkg@1.0.1`.
|
||||
|
||||
If only a single argument `<version-a>` is provided, then the current local file system is going to be compared against that version.
|
||||
|
||||
Here's an example comparing two specific versions (published to the configured registry) of the current project directory:
|
||||
|
||||
```bash
|
||||
npm diff --diff=1.0.0 --diff=1.1.0
|
||||
```
|
||||
|
||||
Note that tag names are not valid `--diff` argument values, if you wish to compare to a published tag, you must use the `pkg@tagname` syntax.
|
||||
|
||||
#### Filtering files
|
||||
|
||||
It's possible to also specify positional arguments using file names or globs pattern matching in order to limit the result of diff patches to only a subset of files for a given package, e.g:
|
||||
|
||||
```bash
|
||||
npm diff --diff=pkg@2 ./lib/ CHANGELOG.md
|
||||
```
|
||||
|
||||
In the example above the diff output is only going to print contents of files located within the folder `./lib/` and changed lines of code within the `CHANGELOG.md` file.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `diff`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Define arguments to compare in `npm diff`.
|
||||
|
||||
|
||||
|
||||
#### `diff-name-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Prints only filenames when using `npm diff`.
|
||||
|
||||
|
||||
|
||||
#### `diff-unified`
|
||||
|
||||
* Default: 3
|
||||
* Type: Number
|
||||
|
||||
The number of lines of context to print in `npm diff`.
|
||||
|
||||
|
||||
|
||||
#### `diff-ignore-all-space`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Ignore whitespace when comparing lines in `npm diff`.
|
||||
|
||||
|
||||
|
||||
#### `diff-no-prefix`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Do not show any source or destination prefix in `npm diff` output.
|
||||
|
||||
Note: this causes `npm diff` to ignore the `--diff-src-prefix` and
|
||||
`--diff-dst-prefix` configs.
|
||||
|
||||
|
||||
|
||||
#### `diff-src-prefix`
|
||||
|
||||
* Default: "a/"
|
||||
* Type: String
|
||||
|
||||
Source prefix to be used in `npm diff` output.
|
||||
|
||||
|
||||
|
||||
#### `diff-dst-prefix`
|
||||
|
||||
* Default: "b/"
|
||||
* Type: String
|
||||
|
||||
Destination prefix to be used in `npm diff` output.
|
||||
|
||||
|
||||
|
||||
#### `diff-text`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Treat all files as text in `npm diff`.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `tag`
|
||||
|
||||
* Default: "latest"
|
||||
* Type: String
|
||||
|
||||
If you ask npm to install a package and don't tell it a specific version,
|
||||
then it will install the specified tag.
|
||||
|
||||
It is the tag added to the package@version specified in the `npm dist-tag
|
||||
add` command, if no explicit tag is given.
|
||||
|
||||
When used by the `npm diff` command, this is the tag used to fetch the
|
||||
tarball that will be compared with the local files by default.
|
||||
|
||||
If used in the `npm publish` command, this is the tag that will be added to
|
||||
the package submitted to the registry.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
## See Also
|
||||
|
||||
* [npm outdated](/commands/npm-outdated)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm registry](/using-npm/registry)
|
||||
Generated
Vendored
+138
@@ -0,0 +1,138 @@
|
||||
---
|
||||
title: npm-dist-tag
|
||||
section: 1
|
||||
description: Modify package distribution tags
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm dist-tag add <package-spec (with version)> [<tag>]
|
||||
npm dist-tag rm <package-spec> <tag>
|
||||
npm dist-tag ls [<package-spec>]
|
||||
|
||||
alias: dist-tags
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Add, remove, and enumerate distribution tags on a package:
|
||||
|
||||
* add: Tags the specified version of the package with the specified tag, or the [`--tag` config](/using-npm/config#tag) if not specified.
|
||||
If you have two-factor authentication on auth-and-writes then you’ll need to include a one-time password on the command line with `--otp <one-time password>`, or go through a second factor flow based on your `authtype`.
|
||||
|
||||
* rm: Clear a tag that is no longer in use from the package.
|
||||
If you have two-factor authentication on auth-and-writes then you’ll need to include a one-time password on the command line with `--otp <one-time password>`, or go through a second factor flow based on your `authtype`
|
||||
|
||||
* 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.
|
||||
|
||||
A tag can be used when installing packages as a reference to a version instead of using a specific version number:
|
||||
|
||||
```bash
|
||||
npm install <name>@<tag>
|
||||
```
|
||||
|
||||
When installing dependencies, a preferred tagged version may be specified:
|
||||
|
||||
```bash
|
||||
npm install --tag <tag>
|
||||
```
|
||||
|
||||
(This also applies to any other commands that resolve and install dependencies, such as `npm dedupe`, `npm update`, and `npm audit fix`.)
|
||||
|
||||
Publishing a package sets the `latest` tag to the published version unless the `--tag` option is used.
|
||||
For example, `npm publish --tag=beta`.
|
||||
|
||||
By default, `npm install <pkg>` (without any `@<version>` or `@<tag>` specifier) installs the `latest` tag.
|
||||
|
||||
### Purpose
|
||||
|
||||
Tags can be used to provide an alias instead of version numbers.
|
||||
|
||||
For example, a project might choose to have multiple streams of development and use a different tag for each stream, e.g., `stable`, `beta`, `dev`,
|
||||
`canary`.
|
||||
|
||||
By default, the `latest` tag is used by npm to identify the current version of a package, and `npm install <pkg>` (without any `@<version>` or `@<tag>` specifier) installs the `latest` tag.
|
||||
Typically, projects only use the `latest` tag for stable release versions, and use other tags for unstable versions such as prereleases.
|
||||
|
||||
The `next` tag is used by some projects to identify the upcoming version.
|
||||
|
||||
Other than `latest`, no tag has any special significance to npm itself.
|
||||
|
||||
### Caveats
|
||||
|
||||
This command used to be known as `npm tag`, which only created new tags, and so had a different syntax.
|
||||
|
||||
Tags must share a namespace with version numbers, because they are specified in the same slot: `npm install <pkg>@<version>` vs `npm install <pkg>@<tag>`.
|
||||
|
||||
Tags that can be interpreted as valid semver ranges will be rejected.
|
||||
For example, `v1.4` cannot be used as a tag, because it is interpreted by semver as `>=1.4.0 <1.5.0`.
|
||||
See <https://github.com/npm/npm/issues/6082>.
|
||||
|
||||
The simplest way to avoid semver problems with tags is to use tags that do not begin with a number or the letter `v`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm dedupe](/commands/npm-dedupe)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
---
|
||||
title: npm-docs
|
||||
section: 1
|
||||
description: Open documentation for a package in a web browser
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm docs [<pkgname> [<pkgname> ...]]
|
||||
|
||||
alias: home
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command tries to guess at the likely location of a package's documentation URL, and then tries to open it using the [`--browser` config](/using-npm/config#browser) param.
|
||||
You can pass multiple package names at once.
|
||||
If no package name is provided, it will search for a `package.json` in the current folder and use the `name` property.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `browser`
|
||||
|
||||
* Default: macOS: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
|
||||
* Type: null, Boolean, or String
|
||||
|
||||
The browser that is called by npm commands to open websites.
|
||||
|
||||
Set to `false` to suppress browser behavior and instead print urls to
|
||||
terminal.
|
||||
|
||||
Set to `true` to use default system URL opener.
|
||||
|
||||
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm view](/commands/npm-view)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
Generated
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: npm-doctor
|
||||
section: 1
|
||||
description: Check the health of your npm environment
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm doctor [connection] [registry] [versions] [environment] [permissions] [cache]
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
`npm doctor` 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:
|
||||
|
||||
+ Node.js and git must be executable by npm.
|
||||
+ The primary npm registry, `registry.npmjs.com`, or another service that uses the registry API, is available.
|
||||
+ The directories that npm uses, `node_modules` (both locally and globally), exist and can be written by the current user.
|
||||
+ The npm cache exists, and the package tarballs within it aren't corrupt.
|
||||
|
||||
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 `npm doctor` confirms that the npm installation is in a good state.
|
||||
|
||||
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 `npm@latest` is better than an old version.
|
||||
|
||||
`npm doctor` verifies the following items in your environment, and if there are any recommended changes, it will display them.
|
||||
By default npm runs all of these checks.
|
||||
You can limit what checks are ran by specifying them as extra arguments.
|
||||
|
||||
#### `Connecting to the registry`
|
||||
|
||||
By default, npm installs from the primary npm registry,
|
||||
`registry.npmjs.org`.
|
||||
`npm doctor` hits a special connection testing endpoint within the registry.
|
||||
This can also be checked with `npm ping`.
|
||||
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 `registry.npmjs.org`.
|
||||
|
||||
This check is done against whichever registry you've configured (you can see what that is by running `npm config get registry`), and if you're using a private registry that doesn't support the `/whoami` endpoint supported by the primary registry, this check may fail.
|
||||
|
||||
#### `Checking npm version`
|
||||
|
||||
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 `npm@latest` 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.
|
||||
|
||||
#### `Checking node version`
|
||||
|
||||
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 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.
|
||||
|
||||
#### `Checking configured npm registry`
|
||||
|
||||
You may be installing from private package registries for your project or company.
|
||||
That's great! Others 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 `npm doctor` just lets you, and maybe whoever's helping you with support, know that you're not using the default registry.
|
||||
|
||||
#### `Checking for git executable in PATH`
|
||||
|
||||
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 `PATH` so that npm can find it.
|
||||
This check ensures that Git is available.
|
||||
|
||||
#### Permissions checks
|
||||
|
||||
* Your cache must be readable and writable by the user running npm.
|
||||
* Global package binaries must be writable by the user running npm.
|
||||
* Your local `node_modules` path, if you're running `npm doctor` with a project directory, must be readable and writable by the user running npm.
|
||||
|
||||
#### Validate the checksums of cached packages
|
||||
|
||||
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.
|
||||
`npm doctor` uses these checksums to validate the package tarballs in your local cache (you can see where that cache is located with `npm config get cache`).
|
||||
In the event that there are corrupt packages in your cache, you should probably run `npm cache clean -f` and reset the cache.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm bugs](/commands/npm-bugs)
|
||||
* [npm help](/commands/npm-help)
|
||||
* [npm ping](/commands/npm-ping)
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
---
|
||||
title: npm-edit
|
||||
section: 1
|
||||
description: Edit an installed package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm edit <pkg>[/<subpkg>...]
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Selects a dependency in the current project and opens the package folder in the default editor (or whatever you've configured as the npm `editor` config -- see [`npm-config`](npm-config).)
|
||||
|
||||
After it has been edited, the package is rebuilt so as to pick up any changes in compiled packages.
|
||||
|
||||
For instance, you can do `npm install connect` to install connect into your package, and then `npm edit connect` to make a few changes to your locally installed copy.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `editor`
|
||||
|
||||
* Default: The EDITOR or VISUAL environment variables, or
|
||||
'%SYSTEMROOT%\notepad.exe' on Windows, or 'vi' on Unix systems
|
||||
* Type: String
|
||||
|
||||
The command to run for `npm edit` and `npm config edit`.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm explore](/commands/npm-explore)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
+364
@@ -0,0 +1,364 @@
|
||||
---
|
||||
title: npm-exec
|
||||
section: 1
|
||||
description: Run a command from a local or remote npm package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm exec -- <pkg>[@<version>] [args...]
|
||||
npm exec --package=<pkg>[@<version>] -- <cmd> [args...]
|
||||
npm exec -c '<cmd> [args...]'
|
||||
npm exec --package=foo -c '<cmd> [args...]'
|
||||
|
||||
alias: x
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command allows you to run an arbitrary command from an npm package (either one installed locally, or fetched remotely), in a similar context as running it via `npm run`.
|
||||
|
||||
Run without positional arguments or `--call`, this allows you to interactively run commands in the same sort of shell environment that `package.json` scripts are run.
|
||||
Interactive mode is not supported in CI environments when standard input is a TTY, to prevent hangs.
|
||||
|
||||
Whatever packages are specified by the `--package` option will be provided in the `PATH` of the executed command, along with any locally installed package executables.
|
||||
The `--package` option may be specified multiple times, to execute the supplied command in an environment where all specified packages are available.
|
||||
|
||||
If any requested packages are not present in the local project dependencies, then a prompt is printed, which can be suppressed by providing either `--yes` or `--no`.
|
||||
When standard input is not a TTY or a CI environment is detected, `--yes` is assumed.
|
||||
The requested packages are installed to a folder in the npm cache, which is added to the `PATH` environment variable in the executed process.
|
||||
|
||||
Package names provided without a specifier will be matched with whatever version exists in the local project.
|
||||
Package names with a specifier will only be considered a match if they have the exact same name and version as the local dependency.
|
||||
|
||||
If no `-c` or `--call` option is provided, then the positional arguments are used to generate the command string.
|
||||
If no `--package` options are provided, then npm will attempt to determine the executable name from the package specifier provided as the first positional argument according to the following heuristic:
|
||||
|
||||
- If the package has a single entry in its `bin` field in `package.json`, or if all entries are aliases of the same command, then that command will be used.
|
||||
- If the package has multiple `bin` entries, and one of them matches the unscoped portion of the `name` field, then that command will be used.
|
||||
- If this does not result in exactly one option (either because there are no bin entries, or none of them match the `name` of the package), then `npm exec` exits with an error.
|
||||
|
||||
To run a binary _other than_ the named binary, specify one or more `--package` options, which will prevent npm from inferring the package from the first command argument.
|
||||
|
||||
### `npx` vs `npm exec`
|
||||
|
||||
When run via the `npx` binary, all flags and options *must* be set prior to any positional arguments.
|
||||
When run via `npm exec`, a double-hyphen `--` flag can be used to suppress npm's parsing of switches and options that should be sent to the executed command.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
$ npx foo@latest bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
In this case, npm will resolve the `foo` package name, and run the following command:
|
||||
|
||||
```
|
||||
$ foo bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
Since the `--package` option comes _after_ the positional arguments, it is treated as an argument to the executed command.
|
||||
|
||||
In contrast, due to npm's argument parsing logic, running this command is different:
|
||||
|
||||
```
|
||||
$ npm exec foo@latest bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
In this case, npm will parse the `--package` option first, resolving the `@npmcli/foo` package.
|
||||
Then, it will execute the following command in that context:
|
||||
|
||||
```
|
||||
$ foo@latest bar
|
||||
```
|
||||
|
||||
The double-hyphen character is recommended to explicitly tell npm to stop parsing command line options and switches.
|
||||
The following command would thus be equivalent to the `npx` command above:
|
||||
|
||||
```
|
||||
$ npm exec -- foo@latest bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `package`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
The package or packages to install for [`npm exec`](/commands/npm-exec)
|
||||
|
||||
|
||||
|
||||
#### `call`
|
||||
|
||||
* Default: ""
|
||||
* Type: String
|
||||
|
||||
Optional companion option for `npm exec`, `npx` that allows for specifying a
|
||||
custom command to be run along with the installed packages.
|
||||
|
||||
```bash
|
||||
npm exec --package yo --package generator-node --call "yo node"
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `allow-scripts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Comma-separated list of packages whose install-time lifecycle scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
dependencies) are allowed to run.
|
||||
|
||||
This setting is intended for one-off and global contexts: `npm exec`, `npx`,
|
||||
and `npm install -g`, where no project `package.json` is involved. For
|
||||
team-wide policy in a project, use the `allowScripts` field in
|
||||
`package.json` (which also supports explicit denials), or configure it in
|
||||
`.npmrc`. Passing `--allow-scripts` on the command line during a
|
||||
project-scoped `npm install`, `ci`, `update`, or `rebuild` is an error.
|
||||
|
||||
Each name is matched against a dependency's resolved identity, not against
|
||||
the package's self-reported name. `--ignore-scripts` and
|
||||
`--dangerously-allow-all-scripts` both override this setting.
|
||||
|
||||
|
||||
|
||||
#### `strict-allow-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, turn the install-script policy from a warning into a hard error:
|
||||
any dependency with install scripts not covered by `allowScripts` will fail
|
||||
the install instead of running with a notice.
|
||||
|
||||
Dependencies explicitly denied with `false` in `allowScripts` are always
|
||||
silently skipped; this setting only affects unreviewed entries.
|
||||
`--ignore-scripts` and `--dangerously-allow-all-scripts` both override this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `dangerously-allow-all-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, bypass the `allowScripts` policy entirely and run every
|
||||
dependency install script regardless of whether it was approved or denied.
|
||||
Intended as a migration escape hatch only; its use is strongly discouraged.
|
||||
`--ignore-scripts` still takes precedence over this setting.
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
Run the version of `tap` in the local dependencies, with the provided arguments:
|
||||
|
||||
```
|
||||
$ npm exec -- tap --bail test/foo.js
|
||||
$ npx tap --bail test/foo.js
|
||||
```
|
||||
|
||||
Run a command _other than_ the command whose name matches the package name by specifying a `--package` option:
|
||||
|
||||
```
|
||||
$ npm exec --package=foo -- bar --bar-argument
|
||||
# ~ or ~
|
||||
$ npx --package=foo bar --bar-argument
|
||||
```
|
||||
|
||||
Run an arbitrary shell script, in the context of the current project:
|
||||
|
||||
```
|
||||
$ npm x -c 'eslint && say "hooray, lint passed"'
|
||||
$ npx -c 'eslint && say "hooray, lint passed"'
|
||||
```
|
||||
|
||||
### Workspaces support
|
||||
|
||||
You may use the [`workspace`](/using-npm/config#workspace) or [`workspaces`](/using-npm/config#workspaces) configs in order to run an arbitrary command from an npm package (either one installed locally, or fetched remotely) in the context of the specified workspaces.
|
||||
If no positional argument or `--call` option is provided, it will open an interactive subshell in the context of each of these configured workspaces one at a time.
|
||||
|
||||
Given a project with configured workspaces, e.g:
|
||||
|
||||
```
|
||||
.
|
||||
+-- package.json
|
||||
`-- packages
|
||||
+-- a
|
||||
| `-- package.json
|
||||
+-- b
|
||||
| `-- package.json
|
||||
`-- c
|
||||
`-- package.json
|
||||
```
|
||||
|
||||
Assuming the workspace configuration is properly set up at the root level `package.json` file.
|
||||
e.g:
|
||||
|
||||
```
|
||||
{
|
||||
"workspaces": [ "./packages/*" ]
|
||||
}
|
||||
```
|
||||
|
||||
You can execute an arbitrary command from a package in the context of each of the configured workspaces when using the [`workspaces` config options](/using-npm/config#workspace), in this example we're using **eslint** to lint any js file found within each workspace folder:
|
||||
|
||||
```
|
||||
npm exec --ws -- eslint ./*.js
|
||||
```
|
||||
|
||||
#### Filtering workspaces
|
||||
|
||||
It's also possible to execute a command in a single workspace using the `workspace` config along with a name or directory path:
|
||||
|
||||
```
|
||||
npm exec --workspace=a -- eslint ./*.js
|
||||
```
|
||||
|
||||
The `workspace` config can also be specified multiple times in order to run a specific script in the context of multiple workspaces.
|
||||
When defining values for the `workspace` config in the command line, it also possible to use `-w` as a shorthand, e.g:
|
||||
|
||||
```
|
||||
npm exec -w a -w b -- eslint ./*.js
|
||||
```
|
||||
|
||||
This last command will run the `eslint` command in both `./packages/a` and
|
||||
`./packages/b` folders.
|
||||
|
||||
### Compatibility with Older npx Versions
|
||||
|
||||
The `npx` binary was rewritten in npm v7.0.0, and the standalone `npx` package deprecated at that time.
|
||||
`npx` uses the `npm exec` command instead of a separate argument parser and install process, with some affordances to maintain backwards compatibility with the arguments it accepted in previous versions.
|
||||
|
||||
This resulted in some shifts in its functionality:
|
||||
|
||||
- Any `npm` config value may be provided.
|
||||
- To prevent security and user-experience problems from mistyping package
|
||||
names, `npx` prompts before installing anything.
|
||||
Suppress this prompt with the `-y` or `--yes` option.
|
||||
- The `--no-install` option is deprecated, and will be converted to `--no`.
|
||||
- Shell fallback functionality is removed, as it is not advisable.
|
||||
- The `-p` argument is a shorthand for `--parseable` in npm, but shorthand for `--package` in npx.
|
||||
This is maintained, but only for the `npx` executable.
|
||||
- The `--ignore-existing` option is removed.
|
||||
Locally installed bins are always present in the executed process `PATH`.
|
||||
- The `--npm` option is removed.
|
||||
`npx` will always use the `npm` it ships with.
|
||||
- The `--node-arg` and `-n` options are removed.
|
||||
- The `--always-spawn` option is redundant, and thus removed.
|
||||
- The `--shell` option is replaced with `--script-shell`, but maintained in the `npx` executable for backwards compatibility.
|
||||
|
||||
### A note on caching
|
||||
|
||||
The npm cli utilizes its internal package cache when using the package name specified.
|
||||
You can use the following to change how and when the cli uses this cache.
|
||||
See [`npm cache`](/commands/npm-cache) for more on how the cache works.
|
||||
|
||||
#### prefer-online
|
||||
|
||||
Forces staleness checks for packages, making the cli look for updates immediately even if the package is already in the cache.
|
||||
|
||||
#### prefer-offline
|
||||
|
||||
Bypasses staleness checks for packages.
|
||||
Missing data will still be requested from the server.
|
||||
To force full offline mode, use `offline`.
|
||||
|
||||
#### offline
|
||||
|
||||
Forces full offline mode.
|
||||
Any packages not locally cached will result in an error.
|
||||
|
||||
#### workspace
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result to selecting all of the nested workspaces)
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### workspaces
|
||||
|
||||
* Alias: `--ws`
|
||||
* Type: Boolean
|
||||
* Default: `false`
|
||||
|
||||
Run scripts in the context of all configured workspaces for the current project.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm test](/commands/npm-test)
|
||||
* [npm start](/commands/npm-start)
|
||||
* [npm restart](/commands/npm-restart)
|
||||
* [npm stop](/commands/npm-stop)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm workspaces](/using-npm/workspaces)
|
||||
* [npx](/commands/npx)
|
||||
Generated
Vendored
+101
@@ -0,0 +1,101 @@
|
||||
---
|
||||
title: npm-explain
|
||||
section: 1
|
||||
description: Explain installed packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm explain <package-spec>
|
||||
|
||||
alias: why
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command will print the chain of dependencies causing a given package to be installed in the current project.
|
||||
|
||||
If one or more package specs are provided, then only packages matching one of the specifiers will have their relationships explained.
|
||||
|
||||
The package spec can also refer to a folder within `./node_modules`
|
||||
|
||||
For example, running `npm explain glob` within npm's source tree will show:
|
||||
|
||||
```bash
|
||||
glob@7.1.6
|
||||
node_modules/glob
|
||||
glob@"^7.1.4" from the root project
|
||||
|
||||
glob@7.1.1 dev
|
||||
node_modules/tacks/node_modules/glob
|
||||
glob@"^7.0.5" from rimraf@2.6.2
|
||||
node_modules/tacks/node_modules/rimraf
|
||||
rimraf@"^2.6.2" from tacks@1.3.0
|
||||
node_modules/tacks
|
||||
dev tacks@"^1.3.0" from the root project
|
||||
```
|
||||
|
||||
To explain just the package residing at a specific folder, pass that as the argument to the command.
|
||||
This can be useful when trying to figure out exactly why a given dependency is being duplicated to satisfy conflicting version requirements within the project.
|
||||
|
||||
```bash
|
||||
$ npm explain node_modules/nyc/node_modules/find-up
|
||||
find-up@3.0.0 dev
|
||||
node_modules/nyc/node_modules/find-up
|
||||
find-up@"^3.0.0" from nyc@14.1.1
|
||||
node_modules/nyc
|
||||
nyc@"^14.1.1" from tap@14.10.8
|
||||
node_modules/tap
|
||||
dev tap@"^14.10.8" from the root project
|
||||
```
|
||||
|
||||
### Configuration
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm ls](/commands/npm-ls)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm link](/commands/npm-link)
|
||||
* [npm prune](/commands/npm-prune)
|
||||
* [npm outdated](/commands/npm-outdated)
|
||||
* [npm update](/commands/npm-update)
|
||||
Generated
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
---
|
||||
title: npm-explore
|
||||
section: 1
|
||||
description: Browse an installed package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm explore <pkg> [ -- <command>]
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Spawn a subshell in the directory of the installed package specified.
|
||||
|
||||
If a command is specified, then it is run in the subshell, which then immediately terminates.
|
||||
|
||||
This is particularly handy in the case of git submodules in the `node_modules` folder:
|
||||
|
||||
```bash
|
||||
npm explore some-dependency -- git pull origin master
|
||||
```
|
||||
|
||||
Note that the package is *not* automatically rebuilt afterwards, so be sure to use `npm rebuild <pkg>` if you make any changes.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `shell`
|
||||
|
||||
* Default: SHELL environment variable, or "bash" on Posix, or "cmd.exe" on
|
||||
Windows
|
||||
* Type: String
|
||||
|
||||
The shell to run for the `npm explore` command.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm edit](/commands/npm-edit)
|
||||
* [npm rebuild](/commands/npm-rebuild)
|
||||
* [npm install](/commands/npm-install)
|
||||
Generated
Vendored
+245
@@ -0,0 +1,245 @@
|
||||
---
|
||||
title: npm-find-dupes
|
||||
section: 1
|
||||
description: Find duplication in the package tree
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm find-dupes
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Runs `npm dedupe` in `--dry-run` mode, making npm only output the duplications, without actually changing the package tree.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `package-lock`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to false, then ignore `package-lock.json` files when installing. This
|
||||
will also prevent _writing_ `package-lock.json` if `save` is true.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm dedupe](/commands/npm-dedupe)
|
||||
* [npm ls](/commands/npm-ls)
|
||||
* [npm update](/commands/npm-update)
|
||||
* [npm install](/commands/npm-install)
|
||||
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
---
|
||||
title: npm-fund
|
||||
section: 1
|
||||
description: Retrieve funding information
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm fund [<package-spec>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
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, listing 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 [`--browser` config](/using-npm/config#browser) param; if there are multiple funding sources for the package, the user will be instructed to pass the
|
||||
`--which` option to disambiguate.
|
||||
|
||||
The list will avoid duplicated entries and will stack all packages that share the same url as a single entry.
|
||||
Thus, the list does not have the same shape of the output from `npm ls`.
|
||||
|
||||
#### Example
|
||||
|
||||
### Workspaces support
|
||||
|
||||
It's possible to filter the results to only include a single workspace and its dependencies using the [`workspace` config](/using-npm/config#workspace) option.
|
||||
|
||||
#### Example:
|
||||
|
||||
Here's an example running `npm fund` in a project with a configured workspace `a`:
|
||||
|
||||
```bash
|
||||
$ npm fund
|
||||
test-workspaces-fund@1.0.0
|
||||
+-- https://example.com/a
|
||||
| | `-- a@1.0.0
|
||||
| `-- https://example.com/maintainer
|
||||
| `-- foo@1.0.0
|
||||
+-- https://example.com/npmcli-funding
|
||||
| `-- @npmcli/test-funding
|
||||
`-- https://example.com/org
|
||||
`-- bar@2.0.0
|
||||
```
|
||||
|
||||
And here is an example of the expected result when filtering only by a specific workspace `a` in the same project:
|
||||
|
||||
```bash
|
||||
$ npm fund -w a
|
||||
test-workspaces-fund@1.0.0
|
||||
`-- https://example.com/a
|
||||
| `-- a@1.0.0
|
||||
`-- https://example.com/maintainer
|
||||
`-- foo@2.0.0
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `browser`
|
||||
|
||||
* Default: macOS: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
|
||||
* Type: null, Boolean, or String
|
||||
|
||||
The browser that is called by npm commands to open websites.
|
||||
|
||||
Set to `false` to suppress browser behavior and instead print urls to
|
||||
terminal.
|
||||
|
||||
Set to `true` to use default system URL opener.
|
||||
|
||||
|
||||
|
||||
#### `unicode`
|
||||
|
||||
* Default: false on windows, true on mac/unix systems with a unicode locale,
|
||||
as defined by the `LC_ALL`, `LC_CTYPE`, or `LANG` environment variables.
|
||||
* Type: Boolean
|
||||
|
||||
When set to true, npm uses unicode characters in the tree output. When
|
||||
false, it uses ascii characters instead of unicode glyphs.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `which`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Number
|
||||
|
||||
If there are multiple funding sources, which 1-indexed source URL to open.
|
||||
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm docs](/commands/npm-docs)
|
||||
* [npm ls](/commands/npm-ls)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm workspaces](/using-npm/workspaces)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: npm-get
|
||||
section: 1
|
||||
description: Get a value from the npm configuration
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm get [<key> ...] (See `npm config`)
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Get a value from the npm configuration
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `long`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show extended information in `ls`, `search`, and `help-search`.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm help config](/commands/npm-config)
|
||||
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: npm-help-search
|
||||
section: 1
|
||||
description: Search npm help documentation
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm help-search <text>
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
This command will search the npm markdown documentation files for the terms provided, and then list the results, sorted by relevance.
|
||||
|
||||
If only one result is found, then it will show that help topic.
|
||||
|
||||
If the argument to `npm help` is not a known help topic, then it will call `help-search`.
|
||||
It is rarely if ever necessary to call this command directly.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `long`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show extended information in `ls`, `search`, and `help-search`.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm](/commands/npm)
|
||||
* [npm help](/commands/npm-help)
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: npm-help
|
||||
section: 1
|
||||
description: Get help on npm
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm help <term> [<terms..>]
|
||||
|
||||
alias: hlep
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
If supplied a topic, then show the appropriate documentation page.
|
||||
|
||||
If the topic does not exist, or if multiple terms are provided, then npm will run the `help-search` command to find a match.
|
||||
Note that, if `help-search` finds a single subject, then it will run `help` on that topic, so unique matches are equivalent to specifying a topic name.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `viewer`
|
||||
|
||||
* Default: "man" on Posix, "browser" on Windows
|
||||
* Type: String
|
||||
|
||||
The program to use to view help content.
|
||||
|
||||
Set to `"browser"` to view html help content in the default web browser.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm](/commands/npm)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm help-search](/commands/npm-help-search)
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
---
|
||||
title: npm-init
|
||||
section: 1
|
||||
description: Create a package.json file
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm init <package-spec> (same as `npx create-<package-spec>`)
|
||||
npm init <@scope> (same as `npx <@scope>/create`)
|
||||
|
||||
aliases: create, innit
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
`npm init <initializer>` can be used to set up a new or existing npm package.
|
||||
|
||||
`initializer` in this case is an npm package named `create-<initializer>`,
|
||||
which will be installed by [`npm-exec`](/commands/npm-exec), and then have its main bin executed -- presumably creating or updating `package.json` and running any other initialization-related operations.
|
||||
|
||||
The init command is transformed to a corresponding `npm exec` operation as follows:
|
||||
|
||||
* `npm init foo` -> `npm exec create-foo`
|
||||
* `npm init @usr/foo` -> `npm exec @usr/create-foo`
|
||||
* `npm init @usr` -> `npm exec @usr/create`
|
||||
* `npm init @usr@2.0.0` -> `npm exec @usr/create@2.0.0`
|
||||
* `npm init @usr/foo@2.0.0` -> `npm exec @usr/create-foo@2.0.0`
|
||||
|
||||
If the initializer is omitted (by just calling `npm init`), 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 `-y`/`--yes` to skip the questionnaire altogether.
|
||||
If you pass `--scope`, it will create a scoped package.
|
||||
|
||||
*Note:* if a user already has the `create-<initializer>` package globally installed, that will be what `npm init` uses.
|
||||
If you want npm to use the latest version, or another specific version you must specify it:
|
||||
|
||||
* `npm init foo@latest` # fetches and runs the latest `create-foo` from the registry
|
||||
* `npm init foo@1.2.3` # runs `create-foo@1.2.3` specifically
|
||||
|
||||
#### Forwarding additional options
|
||||
|
||||
Any additional options will be passed directly to the command, so `npm init foo -- --hello` will map to `npm exec -- create-foo --hello`.
|
||||
|
||||
To better illustrate how options are forwarded, here's a more evolved example showing options passed to both the **npm cli** and a create package, both following commands are equivalent:
|
||||
|
||||
- `npm init foo -y --registry=<url> -- --hello -a`
|
||||
- `npm exec -y --registry=<url> -- create-foo --hello -a`
|
||||
|
||||
### Examples
|
||||
|
||||
Create a new React-based project using [`create-react-app`](https://npm.im/create-react-app):
|
||||
|
||||
```bash
|
||||
$ npm init react-app ./my-react-app
|
||||
```
|
||||
|
||||
Create a new `esm`-compatible package using [`create-esm`](https://npm.im/create-esm):
|
||||
|
||||
```bash
|
||||
$ mkdir my-esm-lib && cd my-esm-lib
|
||||
$ npm init esm --yes
|
||||
```
|
||||
|
||||
Generate a plain old package.json using legacy init:
|
||||
|
||||
```bash
|
||||
$ mkdir my-npm-pkg && cd my-npm-pkg
|
||||
$ git init
|
||||
$ npm init
|
||||
```
|
||||
|
||||
Generate it without having it ask any questions:
|
||||
|
||||
```bash
|
||||
$ npm init -y
|
||||
```
|
||||
|
||||
Set the private flag to `true` in package.json:
|
||||
```bash
|
||||
$ npm init --init-private -y
|
||||
```
|
||||
|
||||
### Workspaces support
|
||||
|
||||
It's possible to create a new workspace within your project by using the `workspace` config option.
|
||||
When using `npm init -w <dir>` the cli will create the folders and boilerplate expected while also adding a reference to your project `package.json` `"workspaces": []` property in order to make sure that new generated **workspace** is properly set up as such.
|
||||
|
||||
Given a project with no workspaces, e.g:
|
||||
|
||||
```
|
||||
.
|
||||
+-- package.json
|
||||
```
|
||||
|
||||
You may generate a new workspace using the legacy init:
|
||||
|
||||
```bash
|
||||
$ npm init -w packages/a
|
||||
```
|
||||
|
||||
That will generate a new folder and `package.json` file, while also updating your top-level `package.json` to add the reference to this new workspace:
|
||||
|
||||
```
|
||||
.
|
||||
+-- package.json
|
||||
`-- packages
|
||||
`-- a
|
||||
`-- package.json
|
||||
```
|
||||
|
||||
The workspaces init also supports the `npm init <initializer> -w <dir>` syntax, following the same set of rules explained earlier in the initial
|
||||
**Description** section of this page.
|
||||
Similar to the previous example of creating a new React-based project using [`create-react-app`](https://npm.im/create-react-app), the following syntax will make sure to create the new react app as a nested **workspace** within your project and configure your `package.json` to recognize it as such:
|
||||
|
||||
```bash
|
||||
npm init -w packages/my-react-app react-app .
|
||||
```
|
||||
|
||||
This will make sure to generate your react app as expected, one important consideration to have in mind is that `npm exec` is going to be run in the context of the newly created folder for that workspace, and that's the reason why in this example the initializer uses the initializer name followed with a dot to represent the current directory in that context, e.g: `react-app .`:
|
||||
|
||||
```
|
||||
.
|
||||
+-- package.json
|
||||
`-- packages
|
||||
+-- a
|
||||
| `-- package.json
|
||||
`-- my-react-app
|
||||
+-- README
|
||||
+-- package.json
|
||||
`-- ...
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `init-author-name`
|
||||
|
||||
* Default: ""
|
||||
* Type: String
|
||||
|
||||
The value `npm init` should use by default for the package author's name.
|
||||
|
||||
|
||||
|
||||
#### `init-author-url`
|
||||
|
||||
* Default: ""
|
||||
* Type: "" or URL
|
||||
|
||||
The value `npm init` should use by default for the package author's
|
||||
homepage.
|
||||
|
||||
|
||||
|
||||
#### `init-license`
|
||||
|
||||
* Default: "ISC"
|
||||
* Type: String
|
||||
|
||||
The value `npm init` should use by default for the package license.
|
||||
|
||||
|
||||
|
||||
#### `init-module`
|
||||
|
||||
* Default: "~/.npm-init.js"
|
||||
* Type: Path
|
||||
|
||||
A module that will be loaded by the `npm init` command. See the
|
||||
documentation for the
|
||||
[init-package-json](https://github.com/npm/init-package-json) module for
|
||||
more information, or [npm init](/commands/npm-init).
|
||||
|
||||
|
||||
|
||||
#### `init-type`
|
||||
|
||||
* Default: "commonjs"
|
||||
* Type: String
|
||||
|
||||
The value that `npm init` should use by default for the package.json type
|
||||
field.
|
||||
|
||||
|
||||
|
||||
#### `init-version`
|
||||
|
||||
* Default: "1.0.0"
|
||||
* Type: SemVer string
|
||||
|
||||
The value that `npm init` should use by default for the package version
|
||||
number, if not already set in package.json.
|
||||
|
||||
|
||||
|
||||
#### `init-private`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
The value `npm init` should use by default for the package's private flag.
|
||||
|
||||
|
||||
|
||||
#### `yes`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Automatically answer "yes" to any prompts that npm might print on the
|
||||
command line.
|
||||
|
||||
|
||||
|
||||
#### `force`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Removes various protections against unfortunate side effects, common
|
||||
mistakes, unnecessary performance degradation, and malicious input.
|
||||
|
||||
* Allow clobbering non-npm files in global installs.
|
||||
* Allow the `npm version` command to work on an unclean git repository.
|
||||
* Allow deleting the cache folder with `npm cache clean`.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of npm.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of `node`, even if `--engine-strict` is enabled.
|
||||
* Allow `npm audit fix` to install modules outside your stated dependency
|
||||
range (including SemVer-major changes).
|
||||
* Allow unpublishing all versions of a published package.
|
||||
* Allow conflicting peerDependencies to be installed in the root project.
|
||||
* Implicitly set `--yes` during `npm init`.
|
||||
* Allow clobbering existing values in `npm pkg`
|
||||
* Allow unpublishing of entire packages (not just a single version).
|
||||
|
||||
If you don't have a clear idea of what you want to do, it is strongly
|
||||
recommended that you do not use this option!
|
||||
|
||||
|
||||
|
||||
#### `scope`
|
||||
|
||||
* Default: the scope of the current project, if any, or ""
|
||||
* Type: String
|
||||
|
||||
Associate an operation with a scope for a scoped registry.
|
||||
|
||||
Useful when logging in to or out of a private registry:
|
||||
|
||||
```
|
||||
# log in, linking the scope to the custom registry
|
||||
npm login --scope=@mycorp --registry=https://registry.mycorp.com
|
||||
|
||||
# log out, removing the link and the auth token
|
||||
npm logout --scope=@mycorp
|
||||
```
|
||||
|
||||
This will cause `@mycorp` to be mapped to the registry for future
|
||||
installation of packages specified according to the pattern
|
||||
`@mycorp/package`.
|
||||
|
||||
This will also cause `npm init` to create a scoped package.
|
||||
|
||||
```
|
||||
# accept all defaults, and create a package named "@foo/whatever",
|
||||
# instead of just named "whatever"
|
||||
npm init --scope=@foo --yes
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces-update`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the npm cli will run an update after operations that may
|
||||
possibly change the workspaces installed to the `node_modules` folder.
|
||||
|
||||
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [init-package-json module](http://npm.im/init-package-json)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm version](/commands/npm-version)
|
||||
* [npm scope](/using-npm/scope)
|
||||
* [npm exec](/commands/npm-exec)
|
||||
* [npm workspaces](/using-npm/workspaces)
|
||||
Generated
Vendored
+388
@@ -0,0 +1,388 @@
|
||||
---
|
||||
title: npm-install-ci-test
|
||||
section: 1
|
||||
description: Install a project with a clean slate and run tests
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm install-ci-test
|
||||
|
||||
aliases: cit, clean-install-test, sit
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command runs `npm ci` followed immediately by `npm test`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-directory`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from directories. That
|
||||
is, dependencies that point to a directory instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any directories to be installed. `none` prevents any
|
||||
directories from being installed. `root` only allows directories defined in
|
||||
your project's package.json to be installed. Also allows directory
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-file`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from tarball files. That
|
||||
is, dependencies that point to a local tarball file instead of a version or
|
||||
semver range. Please note that this could leave your tree incomplete and
|
||||
some packages may not function as intended or designed. Changing this
|
||||
setting will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any tarball file to be installed. `none` prevents any tarball
|
||||
file from being installed. `root` only allows tarball files defined in your
|
||||
project's package.json to be installed. Also allows tarball file
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-git`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from git references. That
|
||||
is, dependencies that point to a git repo instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any git dependencies to be fetched and installed. `none`
|
||||
prevents any git dependencies from being fetched and installed. `root` only
|
||||
allows git dependencies defined in your project's package.json to be fetched
|
||||
and installed. Also allows git dependencies to be fetched for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-remote`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from urls. That is,
|
||||
dependencies that point to a tarball url instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any url to be installed. `none` prevents any url from being
|
||||
installed. `root` only allows urls defined in your project's package.json to
|
||||
be installed. Also allows url dependencies to be used for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Comma-separated list of packages whose install-time lifecycle scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
dependencies) are allowed to run.
|
||||
|
||||
This setting is intended for one-off and global contexts: `npm exec`, `npx`,
|
||||
and `npm install -g`, where no project `package.json` is involved. For
|
||||
team-wide policy in a project, use the `allowScripts` field in
|
||||
`package.json` (which also supports explicit denials), or configure it in
|
||||
`.npmrc`. Passing `--allow-scripts` on the command line during a
|
||||
project-scoped `npm install`, `ci`, `update`, or `rebuild` is an error.
|
||||
|
||||
Each name is matched against a dependency's resolved identity, not against
|
||||
the package's self-reported name. `--ignore-scripts` and
|
||||
`--dangerously-allow-all-scripts` both override this setting.
|
||||
|
||||
|
||||
|
||||
#### `strict-allow-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, turn the install-script policy from a warning into a hard error:
|
||||
any dependency with install scripts not covered by `allowScripts` will fail
|
||||
the install instead of running with a notice.
|
||||
|
||||
Dependencies explicitly denied with `false` in `allowScripts` are always
|
||||
silently skipped; this setting only affects unreviewed entries.
|
||||
`--ignore-scripts` and `--dangerously-allow-all-scripts` both override this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `dangerously-allow-all-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, bypass the `allowScripts` policy entirely and run every
|
||||
dependency install script regardless of whether it was approved or denied.
|
||||
Intended as a migration escape hatch only; its use is strongly discouraged.
|
||||
`--ignore-scripts` still takes precedence over this setting.
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install-test](/commands/npm-install-test)
|
||||
* [npm ci](/commands/npm-ci)
|
||||
* [npm test](/commands/npm-test)
|
||||
Generated
Vendored
+537
@@ -0,0 +1,537 @@
|
||||
---
|
||||
title: npm-install-test
|
||||
section: 1
|
||||
description: Install package(s) and run tests
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm install-test [<package-spec> ...]
|
||||
|
||||
alias: it
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command runs an `npm install` followed immediately by an `npm test`.
|
||||
It takes exactly the same arguments as `npm install`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `save`
|
||||
|
||||
* Default: `true` unless when using `npm update` where it defaults to `false`
|
||||
* Type: Boolean
|
||||
|
||||
Save installed packages to a `package.json` file as dependencies.
|
||||
|
||||
When used with the `npm rm` command, removes the dependency from
|
||||
`package.json`.
|
||||
|
||||
Will also prevent writing to `package-lock.json` if set to `false`.
|
||||
|
||||
|
||||
|
||||
#### `save-exact`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Dependencies saved to package.json will be configured with an exact version
|
||||
rather than using npm's default semver range operator.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `prefer-dedupe`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Prefer to deduplicate packages if possible, rather than choosing a newer
|
||||
version of a dependency.
|
||||
|
||||
|
||||
|
||||
#### `package-lock`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to false, then ignore `package-lock.json` files when installing. This
|
||||
will also prevent _writing_ `package-lock.json` if `save` is true.
|
||||
|
||||
|
||||
|
||||
#### `package-lock-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the current operation will only use the `package-lock.json`,
|
||||
ignoring `node_modules`.
|
||||
|
||||
For `update` this means only the `package-lock.json` will be updated,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
For `list` this means the output will be based on the tree described by the
|
||||
`package-lock.json`, rather than the contents of `node_modules`.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-directory`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from directories. That
|
||||
is, dependencies that point to a directory instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any directories to be installed. `none` prevents any
|
||||
directories from being installed. `root` only allows directories defined in
|
||||
your project's package.json to be installed. Also allows directory
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-file`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from tarball files. That
|
||||
is, dependencies that point to a local tarball file instead of a version or
|
||||
semver range. Please note that this could leave your tree incomplete and
|
||||
some packages may not function as intended or designed. Changing this
|
||||
setting will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any tarball file to be installed. `none` prevents any tarball
|
||||
file from being installed. `root` only allows tarball files defined in your
|
||||
project's package.json to be installed. Also allows tarball file
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-git`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from git references. That
|
||||
is, dependencies that point to a git repo instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any git dependencies to be fetched and installed. `none`
|
||||
prevents any git dependencies from being fetched and installed. `root` only
|
||||
allows git dependencies defined in your project's package.json to be fetched
|
||||
and installed. Also allows git dependencies to be fetched for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-remote`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from urls. That is,
|
||||
dependencies that point to a tarball url instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any url to be installed. `none` prevents any url from being
|
||||
installed. `root` only allows urls defined in your project's package.json to
|
||||
be installed. Also allows url dependencies to be used for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Comma-separated list of packages whose install-time lifecycle scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
dependencies) are allowed to run.
|
||||
|
||||
This setting is intended for one-off and global contexts: `npm exec`, `npx`,
|
||||
and `npm install -g`, where no project `package.json` is involved. For
|
||||
team-wide policy in a project, use the `allowScripts` field in
|
||||
`package.json` (which also supports explicit denials), or configure it in
|
||||
`.npmrc`. Passing `--allow-scripts` on the command line during a
|
||||
project-scoped `npm install`, `ci`, `update`, or `rebuild` is an error.
|
||||
|
||||
Each name is matched against a dependency's resolved identity, not against
|
||||
the package's self-reported name. `--ignore-scripts` and
|
||||
`--dangerously-allow-all-scripts` both override this setting.
|
||||
|
||||
|
||||
|
||||
#### `strict-allow-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, turn the install-script policy from a warning into a hard error:
|
||||
any dependency with install scripts not covered by `allowScripts` will fail
|
||||
the install instead of running with a notice.
|
||||
|
||||
Dependencies explicitly denied with `false` in `allowScripts` are always
|
||||
silently skipped; this setting only affects unreviewed entries.
|
||||
`--ignore-scripts` and `--dangerously-allow-all-scripts` both override this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `dangerously-allow-all-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, bypass the `allowScripts` policy entirely and run every
|
||||
dependency install script regardless of whether it was approved or denied.
|
||||
Intended as a migration escape hatch only; its use is strongly discouraged.
|
||||
`--ignore-scripts` still takes precedence over this setting.
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `before`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Date
|
||||
|
||||
If passed to `npm install`, will rebuild the npm tree such that only
|
||||
versions that were available **on or before** the given date are installed.
|
||||
If there are no versions available for the current set of dependencies, the
|
||||
command will error.
|
||||
|
||||
If the requested version is a `dist-tag` and the given tag does not pass the
|
||||
`--before` filter, the most recent version less than or equal to that tag
|
||||
will be used. For example, `foo@latest` might install `foo@1.2` even though
|
||||
`latest` is `2.0`.
|
||||
|
||||
If `before` and `min-release-age` are both set in the same source, `before`
|
||||
wins (an explicit absolute date overrides a relative window). Across
|
||||
sources, the standard precedence applies (cli > env > project > user >
|
||||
global), so a higher-priority source can always relax or override a
|
||||
lower-priority one.
|
||||
|
||||
|
||||
|
||||
#### `min-release-age`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Number
|
||||
|
||||
If set, npm will build the npm tree such that only versions that were
|
||||
available more than the given number of days ago will be installed. If there
|
||||
are no versions available for the current set of dependencies, the command
|
||||
will error.
|
||||
|
||||
This flag is a complement to `before`, which accepts an exact date instead
|
||||
of a relative number of days. The two may coexist (e.g. `min-release-age` in
|
||||
your `.npmrc` is preserved when npm internally spawns a sub-process with
|
||||
`--before` while preparing a `git:` or `github:` dependency); when both
|
||||
apply, `before` wins within a single source and across sources the standard
|
||||
precedence rules apply.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `cpu`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Override CPU architecture of native modules to install. Acceptable values
|
||||
are same as `cpu` field of package.json, which comes from `process.arch`.
|
||||
|
||||
|
||||
|
||||
#### `os`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Override OS of native modules to install. Acceptable values are same as `os`
|
||||
field of package.json, which comes from `process.platform`.
|
||||
|
||||
|
||||
|
||||
#### `libc`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Override libc of native modules to install. Acceptable values are same as
|
||||
`libc` field of package.json
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm install-ci-test](/commands/npm-install-ci-test)
|
||||
* [npm test](/commands/npm-test)
|
||||
Generated
Vendored
+920
@@ -0,0 +1,920 @@
|
||||
---
|
||||
title: npm-install
|
||||
section: 1
|
||||
description: Install a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm install [<package-spec> ...]
|
||||
|
||||
aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command installs a package and any packages that it depends on.
|
||||
If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock file, the installation of dependencies will be driven by that, respecting the following order of precedence:
|
||||
|
||||
* `npm-shrinkwrap.json`
|
||||
* `package-lock.json`
|
||||
* `yarn.lock`
|
||||
|
||||
See [package-lock.json](/configuring-npm/package-lock-json) and [`npm shrinkwrap`](/commands/npm-shrinkwrap).
|
||||
|
||||
#### How `npm install` uses `package-lock.json`
|
||||
|
||||
When you run `npm install` without arguments, npm compares `package.json` and `package-lock.json`:
|
||||
|
||||
* **If the lockfile's resolved versions satisfy the `package.json` ranges:** npm uses the exact versions from `package-lock.json` to ensure reproducible builds across environments.
|
||||
|
||||
* **If the ranges don't match:** npm resolves new versions that satisfy the `package.json` ranges and updates `package-lock.json` accordingly. This happens when you modify version ranges in `package.json` (e.g., changing `^7.0.0` to `^8.0.0`). Note that changing a range within the same major version (e.g., `^7.0.0` to `^7.1.0`) will only update the metadata in the lockfile if the currently installed version still satisfies the new range.
|
||||
|
||||
In essence, `package-lock.json` locks your dependencies to specific versions, but `package.json` is the source of truth for acceptable version ranges. When the lockfile's versions satisfy the `package.json` ranges, the lockfile wins. When they conflict, `package.json` wins and the lockfile is updated.
|
||||
|
||||
If you want to install packages while ensuring that `package.json` is not modified and that both files are strictly in sync, use [`npm ci`](/commands/npm-ci) instead.
|
||||
|
||||
A `package` is:
|
||||
|
||||
* a) a folder containing a program described by a [`package.json`](/configuring-npm/package-json) file
|
||||
* b) a gzipped tarball containing (a)
|
||||
* c) a url that resolves to (b)
|
||||
* d) a `<name>@<version>` that is published on the registry (see [`registry`](/using-npm/registry)) with (c)
|
||||
* e) a `<name>@<tag>` (see [`npm dist-tag`](/commands/npm-dist-tag)) that points to (d)
|
||||
* f) a `<name>` that has a "latest" tag satisfying (e)
|
||||
* g) a `<git remote url>` that resolves to (a)
|
||||
|
||||
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).
|
||||
|
||||
|
||||
* `npm install` (in a package directory, no arguments):
|
||||
|
||||
Install the dependencies to the local `node_modules` folder.
|
||||
|
||||
In global mode (ie, with `-g` or `--global` appended to the command), it installs the current package context (ie, the current working directory) as a global package.
|
||||
|
||||
By default, `npm install` will install all modules listed as dependencies in [`package.json`](/configuring-npm/package-json).
|
||||
|
||||
With the `--production` flag (or when the `NODE_ENV` environment variable is set to `production`), npm will not install modules listed in `devDependencies`.
|
||||
To install all modules listed in both `dependencies` and `devDependencies` when `NODE_ENV` environment variable is set to `production`, you can use `--production=false`.
|
||||
|
||||
> NOTE: The `--production` flag has no particular meaning when adding a dependency to a project.
|
||||
|
||||
* `npm install <folder>`:
|
||||
|
||||
If `<folder>` sits inside the root of your project, its dependencies will be installed and may be hoisted to the top-level `node_modules` as they would for other types of dependencies.
|
||||
If `<folder>` sits outside the root of your project, *npm will not install the package dependencies* in the directory `<folder>`, but it will create a symlink to `<folder>`.
|
||||
|
||||
> NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use the `--install-links` option.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install ../../other-package --install-links
|
||||
npm install ./sub-package
|
||||
```
|
||||
|
||||
* `npm install <tarball file>`:
|
||||
|
||||
Install a package that is sitting on the filesystem.
|
||||
Note: if you just want to link a dev directory into your npm root, you can do this more easily by using [`npm link`](/commands/npm-link).
|
||||
|
||||
Tarball requirements:
|
||||
* The filename *must* use `.tar`, `.tar.gz`, or `.tgz` as the extension.
|
||||
* The package contents should reside in a subfolder inside the tarball (usually it is called `package/`).
|
||||
npm strips one directory layer when installing the package (an equivalent of `tar x --strip-components=1` is run).
|
||||
* The package must contain a `package.json` file with `name` and `version` properties.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install ./package.tgz
|
||||
```
|
||||
|
||||
* `npm install <tarball url>`:
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
npm install https://github.com/indexzero/forever/tarball/v0.5.6
|
||||
```
|
||||
|
||||
* `npm install [<@scope>/]<name>`:
|
||||
|
||||
Do a `<name>@<tag>` install, where `<tag>` is the "tag" config.
|
||||
(See [`config`](/using-npm/config#tag).
|
||||
The config's default value is `latest`.)
|
||||
|
||||
In most cases, this will install the version of the modules tagged as `latest` on the npm registry.
|
||||
|
||||
**Note:** When installing by name without specifying a version or tag, npm prioritizes versions that match the current Node.js version based on the package's `engines` field. If the `latest` tag points to a version incompatible with your current Node.js version, npm will install the newest compatible version instead. To install a specific version regardless of `engines` compatibility, explicitly specify the version or tag: `npm install <name>@latest`.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install sax
|
||||
```
|
||||
|
||||
`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`.
|
||||
|
||||
* `--save-peer`: Package will appear in your `peerDependencies`.
|
||||
|
||||
* `-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 [`scope`](/using-npm/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
|
||||
```
|
||||
|
||||
* `npm install <alias>@npm:<name>`:
|
||||
|
||||
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 [`validate-npm-package-name`](https://www.npmjs.com/package/validate-npm-package-name#naming-rules).
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
* `npm install [<@scope>/]<name>@<tag>`:
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
npm install sax@latest
|
||||
npm install @myorg/mypackage@latest
|
||||
```
|
||||
|
||||
* `npm install [<@scope>/]<name>@<version>`:
|
||||
|
||||
Install the specified version of the package.
|
||||
This will fail if the version has not been published to the registry.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install sax@0.1.1
|
||||
npm install @myorg/privatepackage@1.5.0
|
||||
```
|
||||
|
||||
* `npm install [<@scope>/]<name>@<version range>`:
|
||||
|
||||
Install a version of the package matching the specified version range.
|
||||
This will follow the same rules for resolving dependencies described in [`package.json`](/configuring-npm/package-json).
|
||||
|
||||
Note that most version ranges must be put in quotes so that your shell will treat it as a single argument.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install sax@">=0.1.0 <0.2.0"
|
||||
npm install @myorg/privatepackage@"16 - 17"
|
||||
```
|
||||
|
||||
**Prerelease versions:** By default, version ranges only match stable versions. To include prerelease versions, they must be explicitly specified in the range. Prerelease versions are tied to a specific version triple (major.minor.patch). For example, `^1.2.3-beta.1` will only match prereleases for `1.2.x`, not `1.3.x`. To match all prereleases for a major version, use a range like `^1.0.0-0`, which will include all `1.x.x` prereleases.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install package@^1.2.3-beta.1 # Matches 1.2.3-beta.1, 1.2.3-beta.2, 1.2.4-beta.1, etc.
|
||||
npm install package@^1.0.0-0 # Matches all 1.x.x prereleases and stable versions
|
||||
```
|
||||
|
||||
* `npm install <git remote url>`:
|
||||
|
||||
Installs the package from the hosted git provider, cloning it with `git`.
|
||||
For a full git remote url, only that URL will be attempted.
|
||||
|
||||
```bash
|
||||
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
|
||||
```
|
||||
|
||||
`<protocol>` is one of `git`, `git+ssh`, `git+http`, `git+https`, or
|
||||
`git+file`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that commit.
|
||||
If the commit-ish has the format `#semver:<semver>`, `<semver>` 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 `#<commit-ish>` or `#semver:<semver>` 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 `prepare` script, its `dependencies` and `devDependencies` 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:
|
||||
|
||||
* `GIT_ASKPASS`
|
||||
* `GIT_EXEC_PATH`
|
||||
* `GIT_PROXY_COMMAND`
|
||||
* `GIT_SSH`
|
||||
* `GIT_SSH_COMMAND`
|
||||
* `GIT_SSL_CAINFO`
|
||||
* `GIT_SSL_NO_VERIFY`
|
||||
|
||||
See the git man page for details.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
|
||||
npm install git+ssh://git@github.com:npm/cli#pull/273
|
||||
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
|
||||
```
|
||||
|
||||
* `npm install <githubname>/<githubrepo>[#<commit-ish>]`:
|
||||
* `npm install github:<githubname>/<githubrepo>[#<commit-ish>]`:
|
||||
|
||||
Install the package at `https://github.com/githubname/githubrepo` by attempting to clone it using `git`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that commit.
|
||||
If the commit-ish has the format `#semver:<semver>`, `<semver>` 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 `#<commit-ish>` or `#semver:<semver>` is specified, then the default branch is used.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will be installed if the package has a `prepare` script before the package is done installing.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
npm install mygithubuser/myproject
|
||||
npm install github:mygithubuser/myproject
|
||||
```
|
||||
|
||||
* `npm install gist:[<githubname>/]<gistID>[#<commit-ish>|#semver:<semver>]`:
|
||||
|
||||
Install the package at `https://gist.github.com/gistID` by attempting to clone it using `git`.
|
||||
The GitHub username associated with the gist is optional and will not be saved in `package.json`.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will be installed if the package has a `prepare` script before the package is done installing.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install gist:101a11beef
|
||||
```
|
||||
|
||||
* `npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]`:
|
||||
|
||||
Install the package at `https://bitbucket.org/bitbucketname/bitbucketrepo` by attempting to clone it using `git`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that commit.
|
||||
If the commit-ish has the format `#semver:<semver>`, `<semver>` 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 `#<commit-ish>` or `#semver:<semver>` is specified, then `master` is used.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will be installed if the package has a `prepare` script before the package is done installing.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install bitbucket:mybitbucketuser/myproject
|
||||
```
|
||||
|
||||
* `npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]`:
|
||||
|
||||
Install the package at `https://gitlab.com/gitlabname/gitlabrepo` by attempting to clone it using `git`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that commit.
|
||||
If the commit-ish has the format `#semver:<semver>`, `<semver>` 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 `#<commit-ish>` or `#semver:<semver>` is specified, then `master` is used.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will be installed if the package has a `prepare` script before the package is done installing.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install gitlab:mygitlabuser/myproject
|
||||
npm install gitlab:myusr/myproj#semver:^5.0
|
||||
```
|
||||
|
||||
You may combine multiple arguments and even multiple types of arguments.
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npm install sax@">=0.1.0 <0.2.0" bench supervisor
|
||||
```
|
||||
|
||||
The `--tag` 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.
|
||||
|
||||
**Note:** The `--tag` option only affects packages specified on the command line. It does not override version ranges specified in `package.json`. For example, if `package.json` specifies `"foo": "^1.0.0"` and you run `npm install --tag beta`, npm will still install a version matching `^1.0.0` even if the `beta` tag points to a different version. To install a tagged version, specify the package explicitly: `npm install foo@beta`.
|
||||
|
||||
The `--dry-run` argument will report in the usual way what the install would have done without actually installing anything.
|
||||
|
||||
The `--package-lock-only` argument will only update the `package-lock.json`, instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
The `-f` or `--force` argument will force npm to fetch remote resources even if a local copy exists on disk.
|
||||
|
||||
```bash
|
||||
npm install sax --force
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
See the [`config`](/using-npm/config) help doc.
|
||||
Many of the configuration params have some effect on installation, since that's most of what npm does.
|
||||
|
||||
These are some of the most common options related to installation.
|
||||
|
||||
#### `save`
|
||||
|
||||
* Default: `true` unless when using `npm update` where it defaults to `false`
|
||||
* Type: Boolean
|
||||
|
||||
Save installed packages to a `package.json` file as dependencies.
|
||||
|
||||
When used with the `npm rm` command, removes the dependency from
|
||||
`package.json`.
|
||||
|
||||
Will also prevent writing to `package-lock.json` if set to `false`.
|
||||
|
||||
|
||||
|
||||
#### `save-exact`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Dependencies saved to package.json will be configured with an exact version
|
||||
rather than using npm's default semver range operator.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `prefer-dedupe`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Prefer to deduplicate packages if possible, rather than choosing a newer
|
||||
version of a dependency.
|
||||
|
||||
|
||||
|
||||
#### `package-lock`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to false, then ignore `package-lock.json` files when installing. This
|
||||
will also prevent _writing_ `package-lock.json` if `save` is true.
|
||||
|
||||
|
||||
|
||||
#### `package-lock-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the current operation will only use the `package-lock.json`,
|
||||
ignoring `node_modules`.
|
||||
|
||||
For `update` this means only the `package-lock.json` will be updated,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
For `list` this means the output will be based on the tree described by the
|
||||
`package-lock.json`, rather than the contents of `node_modules`.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-directory`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from directories. That
|
||||
is, dependencies that point to a directory instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any directories to be installed. `none` prevents any
|
||||
directories from being installed. `root` only allows directories defined in
|
||||
your project's package.json to be installed. Also allows directory
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-file`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from tarball files. That
|
||||
is, dependencies that point to a local tarball file instead of a version or
|
||||
semver range. Please note that this could leave your tree incomplete and
|
||||
some packages may not function as intended or designed. Changing this
|
||||
setting will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any tarball file to be installed. `none` prevents any tarball
|
||||
file from being installed. `root` only allows tarball files defined in your
|
||||
project's package.json to be installed. Also allows tarball file
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-git`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from git references. That
|
||||
is, dependencies that point to a git repo instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any git dependencies to be fetched and installed. `none`
|
||||
prevents any git dependencies from being fetched and installed. `root` only
|
||||
allows git dependencies defined in your project's package.json to be fetched
|
||||
and installed. Also allows git dependencies to be fetched for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-remote`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from urls. That is,
|
||||
dependencies that point to a tarball url instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any url to be installed. `none` prevents any url from being
|
||||
installed. `root` only allows urls defined in your project's package.json to
|
||||
be installed. Also allows url dependencies to be used for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Comma-separated list of packages whose install-time lifecycle scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
dependencies) are allowed to run.
|
||||
|
||||
This setting is intended for one-off and global contexts: `npm exec`, `npx`,
|
||||
and `npm install -g`, where no project `package.json` is involved. For
|
||||
team-wide policy in a project, use the `allowScripts` field in
|
||||
`package.json` (which also supports explicit denials), or configure it in
|
||||
`.npmrc`. Passing `--allow-scripts` on the command line during a
|
||||
project-scoped `npm install`, `ci`, `update`, or `rebuild` is an error.
|
||||
|
||||
Each name is matched against a dependency's resolved identity, not against
|
||||
the package's self-reported name. `--ignore-scripts` and
|
||||
`--dangerously-allow-all-scripts` both override this setting.
|
||||
|
||||
|
||||
|
||||
#### `strict-allow-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, turn the install-script policy from a warning into a hard error:
|
||||
any dependency with install scripts not covered by `allowScripts` will fail
|
||||
the install instead of running with a notice.
|
||||
|
||||
Dependencies explicitly denied with `false` in `allowScripts` are always
|
||||
silently skipped; this setting only affects unreviewed entries.
|
||||
`--ignore-scripts` and `--dangerously-allow-all-scripts` both override this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `dangerously-allow-all-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, bypass the `allowScripts` policy entirely and run every
|
||||
dependency install script regardless of whether it was approved or denied.
|
||||
Intended as a migration escape hatch only; its use is strongly discouraged.
|
||||
`--ignore-scripts` still takes precedence over this setting.
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `before`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Date
|
||||
|
||||
If passed to `npm install`, will rebuild the npm tree such that only
|
||||
versions that were available **on or before** the given date are installed.
|
||||
If there are no versions available for the current set of dependencies, the
|
||||
command will error.
|
||||
|
||||
If the requested version is a `dist-tag` and the given tag does not pass the
|
||||
`--before` filter, the most recent version less than or equal to that tag
|
||||
will be used. For example, `foo@latest` might install `foo@1.2` even though
|
||||
`latest` is `2.0`.
|
||||
|
||||
If `before` and `min-release-age` are both set in the same source, `before`
|
||||
wins (an explicit absolute date overrides a relative window). Across
|
||||
sources, the standard precedence applies (cli > env > project > user >
|
||||
global), so a higher-priority source can always relax or override a
|
||||
lower-priority one.
|
||||
|
||||
|
||||
|
||||
#### `min-release-age`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Number
|
||||
|
||||
If set, npm will build the npm tree such that only versions that were
|
||||
available more than the given number of days ago will be installed. If there
|
||||
are no versions available for the current set of dependencies, the command
|
||||
will error.
|
||||
|
||||
This flag is a complement to `before`, which accepts an exact date instead
|
||||
of a relative number of days. The two may coexist (e.g. `min-release-age` in
|
||||
your `.npmrc` is preserved when npm internally spawns a sub-process with
|
||||
`--before` while preparing a `git:` or `github:` dependency); when both
|
||||
apply, `before` wins within a single source and across sources the standard
|
||||
precedence rules apply.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `cpu`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Override CPU architecture of native modules to install. Acceptable values
|
||||
are same as `cpu` field of package.json, which comes from `process.arch`.
|
||||
|
||||
|
||||
|
||||
#### `os`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Override OS of native modules to install. Acceptable values are same as `os`
|
||||
field of package.json, which comes from `process.platform`.
|
||||
|
||||
|
||||
|
||||
#### `libc`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Override libc of native modules to install. Acceptable values are same as
|
||||
`libc` field of package.json
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### Algorithm
|
||||
|
||||
Given a `package{dep}` structure: `A{B,C}, B{C}, C{D}`, the npm install algorithm produces:
|
||||
|
||||
```bash
|
||||
A
|
||||
+-- B
|
||||
+-- C
|
||||
+-- D
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
For `A{B,C}, B{C,D@1}, C{D@2}`, this algorithm produces:
|
||||
|
||||
```bash
|
||||
A
|
||||
+-- B
|
||||
+-- C
|
||||
`-- D@2
|
||||
+-- D@1
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
See [folders](/configuring-npm/folders) for a more detailed description of the specific folder structures that npm creates.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm update](/commands/npm-update)
|
||||
* [npm audit](/commands/npm-audit)
|
||||
* [npm fund](/commands/npm-fund)
|
||||
* [npm link](/commands/npm-link)
|
||||
* [npm rebuild](/commands/npm-rebuild)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm dist-tag](/commands/npm-dist-tag)
|
||||
* [npm uninstall](/commands/npm-uninstall)
|
||||
* [npm shrinkwrap](/commands/npm-shrinkwrap)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [workspaces](/using-npm/workspaces)
|
||||
+448
@@ -0,0 +1,448 @@
|
||||
---
|
||||
title: npm-link
|
||||
section: 1
|
||||
description: Symlink a package folder
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm link [<package-spec>]
|
||||
|
||||
alias: ln
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This is handy for installing your own stuff, so that you can work on it and test iteratively without having to continually rebuild.
|
||||
|
||||
Package linking is a two-step process.
|
||||
|
||||
First, `npm link` in a package folder with no arguments will create a symlink in the global folder `{prefix}/lib/node_modules/<package>` that links to the package where the `npm link` command was executed.
|
||||
It will also link any bins in the package to `{prefix}/bin/{name}`.
|
||||
Note that `npm link` uses the global prefix (see `npm prefix -g` for its value).
|
||||
|
||||
Next, in some other location, `npm link package-name` will create a symbolic link from globally-installed `package-name` to `node_modules/` of the current folder.
|
||||
|
||||
Note that `package-name` is taken from `package.json`, _not_ from the directory name.
|
||||
|
||||
The package name can be optionally prefixed with a scope.
|
||||
See [`scope`](/using-npm/scope).
|
||||
The scope must be preceded by an @-symbol and followed by a slash.
|
||||
|
||||
When creating tarballs for `npm publish`, the linked packages are "snapshotted" to their current state by resolving the symbolic links, if they are included in `bundleDependencies`.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
You may also shortcut the two steps in one.
|
||||
For example, to do the above use-case in a shorter way:
|
||||
|
||||
```bash
|
||||
cd ~/projects/node-bloggy # go into the dir of your main project
|
||||
npm link ../node-redis # link the dir of your dependency
|
||||
```
|
||||
|
||||
The second line is the equivalent of doing:
|
||||
|
||||
```bash
|
||||
(cd ../node-redis; npm link)
|
||||
npm link redis
|
||||
```
|
||||
|
||||
That is, it first creates a global link, and then links the global installation target into your project's `node_modules` folder.
|
||||
|
||||
Note that in this case, you are referring to the directory name,
|
||||
`node-redis`, rather than the package name `redis`.
|
||||
|
||||
If your linked package is scoped (see [`scope`](/using-npm/scope)) your link command must include that scope, e.g.
|
||||
|
||||
```bash
|
||||
npm link @myorg/privatepackage
|
||||
```
|
||||
|
||||
### Caveat
|
||||
|
||||
Note that package dependencies linked in this way are _not_ saved to `package.json` by default, on the assumption that the intention is to have a link stand in for a regular non-link dependency.
|
||||
Otherwise, for example, if you depend on `redis@^3.0.1`, and ran `npm link redis`, it would replace the `^3.0.1` dependency with `file:../path/to/node-redis`, which you probably don't want! Additionally, other users or developers on your project would run into issues if they do not have their folders set up exactly the same as yours.
|
||||
|
||||
If you are adding a _new_ dependency as a link, you should add it to the relevant metadata by running `npm install <dep> --package-lock-only`.
|
||||
|
||||
If you _want_ to save the `file:` reference in your `package.json` and `package-lock.json` files, you can use `npm link <dep> --save` to do so.
|
||||
|
||||
### Workspace Usage
|
||||
|
||||
`npm link <pkg> --workspace <name>` will link the relevant package as a dependency of the specified workspace(s).
|
||||
Note that It may actually be linked into the parent project's `node_modules` folder, if there are no conflicting dependencies.
|
||||
|
||||
`npm link --workspace <name>` will create a global link to the specified workspace(s).
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `save`
|
||||
|
||||
* Default: `true` unless when using `npm update` where it defaults to `false`
|
||||
* Type: Boolean
|
||||
|
||||
Save installed packages to a `package.json` file as dependencies.
|
||||
|
||||
When used with the `npm rm` command, removes the dependency from
|
||||
`package.json`.
|
||||
|
||||
Will also prevent writing to `package-lock.json` if set to `false`.
|
||||
|
||||
|
||||
|
||||
#### `save-exact`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Dependencies saved to package.json will be configured with an exact version
|
||||
rather than using npm's default semver range operator.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `package-lock`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to false, then ignore `package-lock.json` files when installing. This
|
||||
will also prevent _writing_ `package-lock.json` if `save` is true.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-directory`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from directories. That
|
||||
is, dependencies that point to a directory instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any directories to be installed. `none` prevents any
|
||||
directories from being installed. `root` only allows directories defined in
|
||||
your project's package.json to be installed. Also allows directory
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-file`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to install dependencies from tarball files. That
|
||||
is, dependencies that point to a local tarball file instead of a version or
|
||||
semver range. Please note that this could leave your tree incomplete and
|
||||
some packages may not function as intended or designed. Changing this
|
||||
setting will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any tarball file to be installed. `none` prevents any tarball
|
||||
file from being installed. `root` only allows tarball files defined in your
|
||||
project's package.json to be installed. Also allows tarball file
|
||||
dependencies to be used for other commands like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-git`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from git references. That
|
||||
is, dependencies that point to a git repo instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any git dependencies to be fetched and installed. `none`
|
||||
prevents any git dependencies from being fetched and installed. `root` only
|
||||
allows git dependencies defined in your project's package.json to be fetched
|
||||
and installed. Also allows git dependencies to be fetched for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `allow-remote`
|
||||
|
||||
* Default: "all"
|
||||
* Type: "all", "none", or "root"
|
||||
|
||||
Limits the ability for npm to fetch dependencies from urls. That is,
|
||||
dependencies that point to a tarball url instead of a version or semver
|
||||
range. Please note that this could leave your tree incomplete and some
|
||||
packages may not function as intended or designed. Changing this setting
|
||||
will not remove dependencies that are already installed.
|
||||
|
||||
`all` allows any url to be installed. `none` prevents any url from being
|
||||
installed. `root` only allows urls defined in your project's package.json to
|
||||
be installed. Also allows url dependencies to be used for other commands
|
||||
like `npm view`
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm developers](/using-npm/developers)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
---
|
||||
title: npm-ll
|
||||
section: 1
|
||||
description: List installed packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm ll [[<@scope>/]<pkg> ...]
|
||||
|
||||
alias: la
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
List installed packages
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `all`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When running `npm outdated` and `npm ls`, setting `--all` will show all
|
||||
outdated or installed packages, rather than only those directly depended
|
||||
upon by the current project.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `long`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show extended information in `ls`, `search`, and `help-search`.
|
||||
|
||||
|
||||
|
||||
#### `parseable`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Output parseable results from commands that write to standard output. For
|
||||
`npm search`, this will be tab-separated table format.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `depth`
|
||||
|
||||
* Default: `Infinity` if `--all` is set; otherwise, `0`
|
||||
* Type: null or Number
|
||||
|
||||
The depth to go when recursing packages for `npm ls`.
|
||||
|
||||
If not set, `npm ls` will show only the immediate dependencies of the root
|
||||
project. If `--all` is set, then npm will show all dependencies by default.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `link`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Used with `npm ls`, limiting output to only those packages that are linked.
|
||||
|
||||
|
||||
|
||||
#### `package-lock-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the current operation will only use the `package-lock.json`,
|
||||
ignoring `node_modules`.
|
||||
|
||||
For `update` this means only the `package-lock.json` will be updated,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
For `list` this means the output will be based on the tree described by the
|
||||
`package-lock.json`, rather than the contents of `node_modules`.
|
||||
|
||||
|
||||
|
||||
#### `unicode`
|
||||
|
||||
* Default: false on windows, true on mac/unix systems with a unicode locale,
|
||||
as defined by the `LC_ALL`, `LC_CTYPE`, or `LANG` environment variables.
|
||||
* Type: Boolean
|
||||
|
||||
When set to true, npm uses unicode characters in the tree output. When
|
||||
false, it uses ascii characters instead of unicode glyphs.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm help config](/commands/npm-config)
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
---
|
||||
title: npm-login
|
||||
section: 1
|
||||
description: Login to a registry user account
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm login
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Verify a user in the specified registry, and save the credentials to the
|
||||
`.npmrc` file.
|
||||
If no registry is specified, the default registry will be used (see [`config`](/using-npm/config)).
|
||||
|
||||
When you run `npm login`, the CLI automatically generates a legacy token of `publish` type.
|
||||
For more information, see [About legacy tokens](/about-access-tokens#about-legacy-tokens).
|
||||
|
||||
When using `legacy` for your `auth-type`, the username and password, are read in from prompts.
|
||||
|
||||
To reset your password, go to <https://www.npmjs.com/forgot>
|
||||
|
||||
To change your email address, go to <https://www.npmjs.com/email-edit>
|
||||
|
||||
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.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `scope`
|
||||
|
||||
* Default: the scope of the current project, if any, or ""
|
||||
* Type: String
|
||||
|
||||
Associate an operation with a scope for a scoped registry.
|
||||
|
||||
Useful when logging in to or out of a private registry:
|
||||
|
||||
```
|
||||
# log in, linking the scope to the custom registry
|
||||
npm login --scope=@mycorp --registry=https://registry.mycorp.com
|
||||
|
||||
# log out, removing the link and the auth token
|
||||
npm logout --scope=@mycorp
|
||||
```
|
||||
|
||||
This will cause `@mycorp` to be mapped to the registry for future
|
||||
installation of packages specified according to the pattern
|
||||
`@mycorp/package`.
|
||||
|
||||
This will also cause `npm init` to create a scoped package.
|
||||
|
||||
```
|
||||
# accept all defaults, and create a package named "@foo/whatever",
|
||||
# instead of just named "whatever"
|
||||
npm init --scope=@foo --yes
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### `auth-type`
|
||||
|
||||
* Default: "web"
|
||||
* Type: "legacy" or "web"
|
||||
|
||||
What authentication strategy to use with `login`. Note that if an `otp`
|
||||
config is given, this value will always be set to `legacy`.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm owner](/commands/npm-owner)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
* [npm token](/commands/npm-token)
|
||||
* [npm profile](/commands/npm-profile)
|
||||
Generated
Vendored
+72
@@ -0,0 +1,72 @@
|
||||
---
|
||||
title: npm-logout
|
||||
section: 1
|
||||
description: Log out of the registry
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm logout
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
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.
|
||||
|
||||
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 _only_ affect the current environment.
|
||||
|
||||
If `--scope` is provided, this will find the credentials for the registry connected to that scope, if set.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `scope`
|
||||
|
||||
* Default: the scope of the current project, if any, or ""
|
||||
* Type: String
|
||||
|
||||
Associate an operation with a scope for a scoped registry.
|
||||
|
||||
Useful when logging in to or out of a private registry:
|
||||
|
||||
```
|
||||
# log in, linking the scope to the custom registry
|
||||
npm login --scope=@mycorp --registry=https://registry.mycorp.com
|
||||
|
||||
# log out, removing the link and the auth token
|
||||
npm logout --scope=@mycorp
|
||||
```
|
||||
|
||||
This will cause `@mycorp` to be mapped to the registry for future
|
||||
installation of packages specified according to the pattern
|
||||
`@mycorp/package`.
|
||||
|
||||
This will also cause `npm init` to create a scoped package.
|
||||
|
||||
```
|
||||
# accept all defaults, and create a package named "@foo/whatever",
|
||||
# instead of just named "whatever"
|
||||
npm init --scope=@foo --yes
|
||||
```
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
---
|
||||
title: npm-ls
|
||||
section: 1
|
||||
description: List installed packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm ls <package-spec>
|
||||
|
||||
alias: list
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command will print to stdout all the versions of packages that are installed, as well as their dependencies when `--all` is specified, in a tree structure.
|
||||
|
||||
Note: to get a "bottoms up" view of why a given package is included in the tree at all, use [`npm explain`](/commands/npm-explain).
|
||||
|
||||
Positional arguments are `name@version-range` identifiers, which will limit the results to only the paths to the packages named.
|
||||
Note that nested packages will *also* show the paths to the specified packages.
|
||||
For example, running `npm ls promzard` in npm's source tree will show:
|
||||
|
||||
```bash
|
||||
npm@11.16.0 /path/to/npm
|
||||
└─┬ init-package-json@0.0.4
|
||||
└── promzard@0.1.5
|
||||
```
|
||||
|
||||
It will print out extraneous, missing, and invalid packages.
|
||||
|
||||
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.
|
||||
|
||||
The tree shown is the logical dependency tree, based on package dependencies, not the physical layout of your `node_modules` folder.
|
||||
|
||||
When run as `ll` or `la`, it shows extended information by default.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `all`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When running `npm outdated` and `npm ls`, setting `--all` will show all
|
||||
outdated or installed packages, rather than only those directly depended
|
||||
upon by the current project.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `long`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show extended information in `ls`, `search`, and `help-search`.
|
||||
|
||||
|
||||
|
||||
#### `parseable`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Output parseable results from commands that write to standard output. For
|
||||
`npm search`, this will be tab-separated table format.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `depth`
|
||||
|
||||
* Default: `Infinity` if `--all` is set; otherwise, `0`
|
||||
* Type: null or Number
|
||||
|
||||
The depth to go when recursing packages for `npm ls`.
|
||||
|
||||
If not set, `npm ls` will show only the immediate dependencies of the root
|
||||
project. If `--all` is set, then npm will show all dependencies by default.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `link`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Used with `npm ls`, limiting output to only those packages that are linked.
|
||||
|
||||
|
||||
|
||||
#### `package-lock-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the current operation will only use the `package-lock.json`,
|
||||
ignoring `node_modules`.
|
||||
|
||||
For `update` this means only the `package-lock.json` will be updated,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
For `list` this means the output will be based on the tree described by the
|
||||
`package-lock.json`, rather than the contents of `node_modules`.
|
||||
|
||||
|
||||
|
||||
#### `unicode`
|
||||
|
||||
* Default: false on windows, true on mac/unix systems with a unicode locale,
|
||||
as defined by the `LC_ALL`, `LC_CTYPE`, or `LANG` environment variables.
|
||||
* Type: Boolean
|
||||
|
||||
When set to true, npm uses unicode characters in the tree output. When
|
||||
false, it uses ascii characters instead of unicode glyphs.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm explain](/commands/npm-explain)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm explain](/commands/npm-explain)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm link](/commands/npm-link)
|
||||
* [npm prune](/commands/npm-prune)
|
||||
* [npm outdated](/commands/npm-outdated)
|
||||
* [npm update](/commands/npm-update)
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
---
|
||||
title: npm-org
|
||||
section: 1
|
||||
description: Manage orgs
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm org set orgname username [developer | admin | owner]
|
||||
npm org rm orgname username
|
||||
npm org ls orgname [<username>]
|
||||
|
||||
alias: ogr
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Example
|
||||
|
||||
Add a new developer to an org:
|
||||
|
||||
```bash
|
||||
$ npm org set my-org @mx-smith
|
||||
```
|
||||
|
||||
Add a new admin to an org (or change a developer to an admin):
|
||||
|
||||
```bash
|
||||
$ npm org set my-org @mx-santos admin
|
||||
```
|
||||
|
||||
Remove a user from an org:
|
||||
|
||||
```bash
|
||||
$ npm org rm my-org mx-santos
|
||||
```
|
||||
|
||||
List all users in an org:
|
||||
|
||||
```bash
|
||||
$ npm org ls my-org
|
||||
```
|
||||
|
||||
List all users in JSON format:
|
||||
|
||||
```bash
|
||||
$ npm org ls my-org --json
|
||||
```
|
||||
|
||||
See what role a user has in an org:
|
||||
|
||||
```bash
|
||||
$ npm org ls my-org @mx-santos
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
You can use the `npm org` 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.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `parseable`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Output parseable results from commands that write to standard output. For
|
||||
`npm search`, this will be tab-separated table format.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [using orgs](/using-npm/orgs)
|
||||
* [Documentation on npm Orgs](https://docs.npmjs.com/orgs/)
|
||||
Generated
Vendored
+202
@@ -0,0 +1,202 @@
|
||||
---
|
||||
title: npm-outdated
|
||||
section: 1
|
||||
description: Check for outdated packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm outdated [<package-spec> ...]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command will check the registry to see if any (or, specific) installed packages are currently outdated.
|
||||
|
||||
By default, only the direct dependencies of the root project and direct dependencies of your configured *workspaces* are shown.
|
||||
Use `--all` to find all outdated meta-dependencies as well.
|
||||
|
||||
In the output:
|
||||
|
||||
* `wanted` is the maximum version of the package that satisfies the semver range specified in `package.json`.
|
||||
If there's no available semver range (i.e. you're running `npm outdated --global`, or the package isn't included in `package.json`), then `wanted` shows the currently-installed version.
|
||||
* `latest` is the version of the package tagged as latest in the registry.
|
||||
Running `npm publish` with no special configuration will publish the package with a dist-tag of `latest`.
|
||||
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](/commands/npm-dist-tag).
|
||||
* `location` is where in the physical tree the package is located.
|
||||
* `depended by` shows which package depends on the displayed dependency
|
||||
* `package type` (when using `--long` / `-l`) tells you whether this package is a `dependency` or a dev/peer/optional dependency.
|
||||
Packages not included in `package.json` are always marked `dependencies`.
|
||||
* `homepage` (when using `--long` / `-l`) is the `homepage` value contained in the package's packument
|
||||
* `depended by location` (when using `--long` / `-l`) shows location of the package that depends on the displayed dependency
|
||||
* Red means there's a newer version matching your semver requirements, so you should update now.
|
||||
* Yellow indicates that there's a newer version _above_ your semver requirements (usually new major, or new 0.x minor) so proceed with caution.
|
||||
|
||||
### An example
|
||||
|
||||
```bash
|
||||
$ npm outdated
|
||||
Package Current Wanted Latest Location Depended by
|
||||
glob 5.0.15 5.0.15 6.0.1 node_modules/glob dependent-package-name
|
||||
nothingness 0.0.3 git git node_modules/nothingness dependent-package-name
|
||||
npm 3.5.1 3.5.2 3.5.1 node_modules/npm dependent-package-name
|
||||
local-dev 0.0.3 linked linked local-dev dependent-package-name
|
||||
once 1.3.2 1.3.3 1.3.3 node_modules/once dependent-package-name
|
||||
```
|
||||
|
||||
With these `dependencies`:
|
||||
```json
|
||||
{
|
||||
"glob": "^5.0.15",
|
||||
"nothingness": "github:othiym23/nothingness#master",
|
||||
"npm": "^3.5.1",
|
||||
"once": "^1.3.1"
|
||||
}
|
||||
```
|
||||
|
||||
A few things to note:
|
||||
|
||||
* `glob` requires `^5`, which prevents npm from installing `glob@6`, which is outside the semver range.
|
||||
* 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 `npm outdated` and `npm update` 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.
|
||||
* `npm@3.5.2` is marked as "wanted", but "latest" is `npm@3.5.1` because npm uses dist-tags to manage its `latest` and `next` release channels.
|
||||
`npm update` will install the _newest_ version, but `npm install npm` (with no semver range) will install whatever's tagged as `latest`.
|
||||
* `once` is just plain out of date.
|
||||
Reinstalling `node_modules` from scratch or running `npm update` will bring it up to spec.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `all`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When running `npm outdated` and `npm ls`, setting `--all` will show all
|
||||
outdated or installed packages, rather than only those directly depended
|
||||
upon by the current project.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `long`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show extended information in `ls`, `search`, and `help-search`.
|
||||
|
||||
|
||||
|
||||
#### `parseable`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Output parseable results from commands that write to standard output. For
|
||||
`npm search`, this will be tab-separated table format.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `before`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Date
|
||||
|
||||
If passed to `npm install`, will rebuild the npm tree such that only
|
||||
versions that were available **on or before** the given date are installed.
|
||||
If there are no versions available for the current set of dependencies, the
|
||||
command will error.
|
||||
|
||||
If the requested version is a `dist-tag` and the given tag does not pass the
|
||||
`--before` filter, the most recent version less than or equal to that tag
|
||||
will be used. For example, `foo@latest` might install `foo@1.2` even though
|
||||
`latest` is `2.0`.
|
||||
|
||||
If `before` and `min-release-age` are both set in the same source, `before`
|
||||
wins (an explicit absolute date overrides a relative window). Across
|
||||
sources, the standard precedence applies (cli > env > project > user >
|
||||
global), so a higher-priority source can always relax or override a
|
||||
lower-priority one.
|
||||
|
||||
|
||||
|
||||
#### `min-release-age`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Number
|
||||
|
||||
If set, npm will build the npm tree such that only versions that were
|
||||
available more than the given number of days ago will be installed. If there
|
||||
are no versions available for the current set of dependencies, the command
|
||||
will error.
|
||||
|
||||
This flag is a complement to `before`, which accepts an exact date instead
|
||||
of a relative number of days. The two may coexist (e.g. `min-release-age` in
|
||||
your `.npmrc` is preserved when npm internally spawns a sub-process with
|
||||
`--before` while preparing a `git:` or `github:` dependency); when both
|
||||
apply, `before` wins within a single source and across sources the standard
|
||||
precedence rules apply.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm update](/commands/npm-update)
|
||||
* [npm dist-tag](/commands/npm-dist-tag)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm workspaces](/using-npm/workspaces)
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
---
|
||||
title: npm-owner
|
||||
section: 1
|
||||
description: Manage package owners
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm owner add <user> <package-spec>
|
||||
npm owner rm <user> <package-spec>
|
||||
npm owner ls <package-spec>
|
||||
|
||||
alias: author
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Manage ownership of published packages.
|
||||
|
||||
* 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.
|
||||
* 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.
|
||||
* rm: Remove a user from the package owner list.
|
||||
This immediately revokes their privileges.
|
||||
|
||||
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.
|
||||
|
||||
If you have two-factor authentication enabled with `auth-and-writes` (see [`npm-profile`](/commands/npm-profile)) then you'll need to go through a second factor flow when changing ownership or include an otp on the command line with `--otp`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm profile](/commands/npm-profile)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
---
|
||||
title: npm-pack
|
||||
section: 1
|
||||
description: Create a tarball from a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm pack <package-spec>
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `pack-destination`
|
||||
|
||||
* Default: "."
|
||||
* Type: String
|
||||
|
||||
Directory in which `npm pack` will save tarballs.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
For anything that's installable (that is, a package folder, tarball, tarball url, git url, name@tag, name@version, name, or scoped name), this command will fetch it to the cache, copy the tarball to the current working directory as `<name>-<version>.tgz`, and then write the filenames out to stdout.
|
||||
|
||||
If the same package is specified multiple times, then the file will be overwritten the second time.
|
||||
|
||||
If no arguments are supplied, then npm packs the current package folder.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm-packlist package](http://npm.im/npm-packlist)
|
||||
* [npm cache](/commands/npm-cache)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
---
|
||||
title: npm-ping
|
||||
section: 1
|
||||
description: Ping npm registry
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm ping
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Ping the configured or given npm registry and verify authentication.
|
||||
If it works it will output something like:
|
||||
|
||||
```bash
|
||||
npm notice PING https://registry.npmjs.org/
|
||||
npm notice PONG 255ms
|
||||
```
|
||||
otherwise you will get an error:
|
||||
```bash
|
||||
npm notice PING http://foo.com/
|
||||
npm ERR! code E404
|
||||
npm ERR! 404 Not Found - GET http://www.foo.com/-/ping?write=true
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm doctor](/commands/npm-doctor)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
---
|
||||
title: npm-pkg
|
||||
section: 1
|
||||
description: Manages your package.json
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm pkg set <key>=<value> [<key>=<value> ...]
|
||||
npm pkg get [<key> [<key> ...]]
|
||||
npm pkg delete <key> [<key> ...]
|
||||
npm pkg set [<array>[<index>].<key>=<value> ...]
|
||||
npm pkg set [<array>[].<key>=<value> ...]
|
||||
npm pkg fix
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
A command that automates the management of `package.json` files.
|
||||
`npm pkg` provide 3 different sub commands that allow you to modify or retrieve values for given object keys in your `package.json`.
|
||||
|
||||
The syntax to retrieve and set fields is a dot separated representation of the nested object properties to be found within your `package.json`, it's the same notation used in [`npm view`](/commands/npm-view) to retrieve information from the registry manifest, below you can find more examples on how to use it.
|
||||
|
||||
Returned values are always in **json** format.
|
||||
|
||||
* `npm pkg get <field>`
|
||||
|
||||
Retrieves a value `key`, defined in your `package.json` file.
|
||||
|
||||
For example, in order to retrieve the name of the current package, you can run:
|
||||
|
||||
```bash
|
||||
npm pkg get name
|
||||
```
|
||||
|
||||
It's also possible to retrieve multiple values at once:
|
||||
|
||||
```bash
|
||||
npm pkg get name version
|
||||
```
|
||||
|
||||
You can view child fields by separating them with a period.
|
||||
To retrieve the value of a test `script` value, you would run the following command:
|
||||
|
||||
```bash
|
||||
npm pkg get scripts.test
|
||||
```
|
||||
|
||||
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 emails for a package, you would run:
|
||||
|
||||
```bash
|
||||
npm pkg get contributors.email
|
||||
```
|
||||
|
||||
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 run:
|
||||
|
||||
```bash
|
||||
npm pkg get contributors[0].email
|
||||
```
|
||||
|
||||
For complex fields you can also name a property in square brackets to specifically select a child field.
|
||||
This is especially helpful with the exports object:
|
||||
|
||||
```bash
|
||||
npm pkg get "exports[.].require"
|
||||
```
|
||||
|
||||
* `npm pkg set <field>=<value>`
|
||||
|
||||
Sets a `value` in your `package.json` based on the `field` value.
|
||||
When saving to your `package.json` file the same set of rules used during `npm install` and other cli commands that touches the `package.json` file are used, making sure to respect the existing indentation and possibly applying some validation prior to saving values to the file.
|
||||
|
||||
The same syntax used to retrieve values from your package can also be used to define new properties or overriding existing ones, below are some examples of how the dot separated syntax can be used to edit your `package.json` file.
|
||||
|
||||
Defining a new bin named `mynewcommand` in your `package.json` that points to a file `cli.js`:
|
||||
|
||||
```bash
|
||||
npm pkg set bin.mynewcommand=cli.js
|
||||
```
|
||||
|
||||
Setting multiple fields at once is also possible:
|
||||
|
||||
```bash
|
||||
npm pkg set description='Awesome package' engines.node='>=10'
|
||||
```
|
||||
|
||||
It's also possible to add to array values, for example to add a new contributor entry:
|
||||
|
||||
```bash
|
||||
npm pkg set contributors[0].name='Foo' contributors[0].email='foo@bar.ca'
|
||||
```
|
||||
|
||||
You may also append items to the end of an array using the special empty bracket notation:
|
||||
|
||||
```bash
|
||||
npm pkg set contributors[].name='Foo' contributors[].name='Bar'
|
||||
```
|
||||
|
||||
It's also possible to parse values as json prior to saving them to your `package.json` file, for example in order to set a `"private": true` property:
|
||||
|
||||
```bash
|
||||
npm pkg set private=true --json
|
||||
```
|
||||
|
||||
It also enables saving values as numbers:
|
||||
|
||||
```bash
|
||||
npm pkg set tap.timeout=60 --json
|
||||
```
|
||||
|
||||
* `npm pkg delete <key>`
|
||||
|
||||
Deletes a `key` from your `package.json`
|
||||
|
||||
The same syntax used to set values from your package can also be used to remove existing ones.
|
||||
For example, in order to remove a script named build:
|
||||
|
||||
```bash
|
||||
npm pkg delete scripts.build
|
||||
```
|
||||
|
||||
* `npm pkg fix`
|
||||
|
||||
Auto corrects common errors in your `package.json`.
|
||||
npm already does this during `publish`, which leads to subtle (mostly harmless) differences between the contents of your `package.json` file and the manifest that npm uses during installation.
|
||||
|
||||
### Workspaces support
|
||||
|
||||
You can set/get/delete items across your configured workspaces by using the [`workspace`](/using-npm/config#workspace) or [`workspaces`](/using-npm/config#workspaces) config options.
|
||||
|
||||
For example, setting a `funding` value across all configured workspaces of a project:
|
||||
|
||||
```bash
|
||||
npm pkg set funding=https://example.com --ws
|
||||
```
|
||||
|
||||
When using `npm pkg get` to retrieve info from your configured workspaces, the returned result will be in a json format in which top level keys are the names of each workspace, the values of these keys will be the result values returned from each of the configured workspaces, e.g:
|
||||
|
||||
```
|
||||
npm pkg get name version --ws
|
||||
{
|
||||
"a": {
|
||||
"name": "a",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"b": {
|
||||
"name": "b",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `force`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Removes various protections against unfortunate side effects, common
|
||||
mistakes, unnecessary performance degradation, and malicious input.
|
||||
|
||||
* Allow clobbering non-npm files in global installs.
|
||||
* Allow the `npm version` command to work on an unclean git repository.
|
||||
* Allow deleting the cache folder with `npm cache clean`.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of npm.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of `node`, even if `--engine-strict` is enabled.
|
||||
* Allow `npm audit fix` to install modules outside your stated dependency
|
||||
range (including SemVer-major changes).
|
||||
* Allow unpublishing all versions of a published package.
|
||||
* Allow conflicting peerDependencies to be installed in the root project.
|
||||
* Implicitly set `--yes` during `npm init`.
|
||||
* Allow clobbering existing values in `npm pkg`
|
||||
* Allow unpublishing of entire packages (not just a single version).
|
||||
|
||||
If you don't have a clear idea of what you want to do, it is strongly
|
||||
recommended that you do not use this option!
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
## See Also
|
||||
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm init](/commands/npm-init)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [workspaces](/using-npm/workspaces)
|
||||
Generated
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: npm-prefix
|
||||
section: 1
|
||||
description: Display prefix
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm prefix
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Print the local prefix to standard output.
|
||||
This is the closest parent directory to contain a `package.json` file or `node_modules` directory, unless `-g` is also specified.
|
||||
|
||||
If `-g` is specified, this will be the value of the global prefix.
|
||||
See [`npm config`](/commands/npm-config) for more detail.
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
npm prefix
|
||||
/usr/local/projects/foo
|
||||
```
|
||||
|
||||
```bash
|
||||
npm prefix -g
|
||||
/usr/local
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm root](/commands/npm-root)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
Generated
Vendored
+115
@@ -0,0 +1,115 @@
|
||||
---
|
||||
title: npm-profile
|
||||
section: 1
|
||||
description: Change settings on your registry profile
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm profile enable-2fa [auth-only|auth-and-writes]
|
||||
npm profile disable-2fa
|
||||
npm profile get [<key>]
|
||||
npm profile set <key> <value>
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Change your profile information on the registry.
|
||||
Note that this command depends on the registry implementation, so third-party registries may not support this interface.
|
||||
|
||||
* `npm profile get [<property>]`: Display all of the properties of your profile, or one or more specific properties.
|
||||
It looks like:
|
||||
|
||||
```
|
||||
name: example
|
||||
email: e@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
|
||||
```
|
||||
|
||||
* `npm profile set <property> <value>`: Set the value of a profile property.
|
||||
You can set the following properties this way: email, fullname, homepage, freenode, twitter, github
|
||||
|
||||
* `npm profile set password`: 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.
|
||||
|
||||
* `npm profile enable-2fa [auth-and-writes|auth-only]`: Enables two-factor authentication.
|
||||
Defaults to `auth-and-writes` mode.
|
||||
Modes are:
|
||||
* `auth-only`: 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.
|
||||
* `auth-and-writes`: Requires an OTP at all the times `auth-only` does, and also requires one when publishing a module, setting the `latest` dist-tag, or changing access via `npm access` and `npm owner`.
|
||||
|
||||
* `npm profile disable-2fa`: Disables two-factor authentication.
|
||||
|
||||
### Details
|
||||
|
||||
Some of these commands may not be available on non npmjs.com registries.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `parseable`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Output parseable results from commands that write to standard output. For
|
||||
`npm search`, this will be tab-separated table format.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm owner](/commands/npm-owner)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
* [npm token](/commands/npm-token)
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
---
|
||||
title: npm-prune
|
||||
section: 1
|
||||
description: Remove extraneous packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm prune [[<@scope>/]<pkg>...]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command removes "extraneous" packages.
|
||||
If a package name is provided, then only packages matching one of the supplied names are removed.
|
||||
|
||||
Extraneous packages are those present in the `node_modules` folder that are not listed as any package's dependency list.
|
||||
|
||||
If the `--omit=dev` flag is specified or the `NODE_ENV` environment variable is set to `production`, this command will remove the packages specified in your `devDependencies`.
|
||||
|
||||
If the `--dry-run` flag is used then no changes will actually be made.
|
||||
|
||||
If the `--json` flag is used, then the changes `npm prune` made (or would have made with `--dry-run`) are printed as a JSON object.
|
||||
|
||||
In normal operation, extraneous modules are pruned automatically, so you'll only need this command with the `--production` flag.
|
||||
However, in the real world, operation is not always "normal". When crashes or mistakes happen, this command can help clean up any resulting garbage.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm uninstall](/commands/npm-uninstall)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm ls](/commands/npm-ls)
|
||||
Generated
Vendored
+247
@@ -0,0 +1,247 @@
|
||||
---
|
||||
title: npm-publish
|
||||
section: 1
|
||||
description: Publish a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm publish <package-spec>
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Publishes a package to the registry so that it can be installed by name.
|
||||
|
||||
### Examples
|
||||
|
||||
Publish the package in the current directory:
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
Publish a specific workspace:
|
||||
|
||||
```bash
|
||||
npm publish --workspace=<workspace-name>
|
||||
```
|
||||
|
||||
Publish multiple workspaces:
|
||||
|
||||
```bash
|
||||
npm publish --workspace=workspace-a --workspace=workspace-b
|
||||
```
|
||||
|
||||
Publish all workspaces:
|
||||
|
||||
```bash
|
||||
npm publish --workspaces
|
||||
```
|
||||
|
||||
By default npm will publish to the public registry.
|
||||
This can be overridden by specifying a different default registry or using a [`scope`](/using-npm/scope) in the name, combined with a scope-configured registry (see [`package.json`](/configuring-npm/package-json)).
|
||||
|
||||
|
||||
A `package` is interpreted the same way as other commands (like `npm install`) and can be:
|
||||
|
||||
* a) a folder containing a program described by a [`package.json`](/configuring-npm/package-json) file
|
||||
* b) a gzipped tarball containing (a)
|
||||
* c) a url that resolves to (b)
|
||||
* d) a `<name>@<version>` that is published on the registry (see [`registry`](/using-npm/registry)) with (c)
|
||||
* e) a `<name>@<tag>` (see [`npm dist-tag`](/commands/npm-dist-tag)) that points to (d)
|
||||
* f) a `<name>` that has a "latest" tag satisfying (e)
|
||||
* g) a `<git remote url>` that resolves to (a)
|
||||
|
||||
If either (a) or (b) is specified as a relative path, it should begin with an explicit `./` prefix.
|
||||
|
||||
The publish will fail if the package name and version combination already exists in the specified registry.
|
||||
|
||||
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 unpublish`](/commands/npm-unpublish).
|
||||
|
||||
As of `npm@5`, 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.
|
||||
|
||||
Similar to `--dry-run` see [`npm pack`](/commands/npm-pack), which figures out the files to be included and packs them into a tarball to be uploaded to the registry.
|
||||
|
||||
### Files included in package
|
||||
|
||||
To see what will be included in your package, run `npm pack --dry-run`.
|
||||
All files are included by default, with the following exceptions:
|
||||
|
||||
- Certain files that are relevant to package installation and distribution are always included.
|
||||
For example, `package.json`, `README.md`,
|
||||
`LICENSE`, and so on.
|
||||
|
||||
- If there is a "files" list in [`package.json`](/configuring-npm/package-json), then only the files specified will be included.
|
||||
(If directories are specified, then they will be walked recursively and their contents included, subject to the same ignore rules.)
|
||||
|
||||
- If there is a `.gitignore` or `.npmignore` file, then ignored files in that and all child directories will be excluded from the package.
|
||||
If _both_ files exist, then the `.gitignore` is ignored, and only the
|
||||
`.npmignore` is used.
|
||||
|
||||
`.npmignore` files follow the [same pattern rules](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring) as `.gitignore` files
|
||||
|
||||
- If the file matches certain patterns, then it will _never_ be included, unless explicitly added to the `"files"` list in `package.json`, or un-ignored with a `!` rule in a `.npmignore` or `.gitignore` file.
|
||||
|
||||
- Symbolic links are never included in npm packages.
|
||||
|
||||
|
||||
See [`developers`](/using-npm/developers) for full details on what's included in the published package, as well as details on how the package is built.
|
||||
|
||||
See [`package.json`](/configuring-npm/package-json) for more info on what can and can't be ignored.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `tag`
|
||||
|
||||
* Default: "latest"
|
||||
* Type: String
|
||||
|
||||
If you ask npm to install a package and don't tell it a specific version,
|
||||
then it will install the specified tag.
|
||||
|
||||
It is the tag added to the package@version specified in the `npm dist-tag
|
||||
add` command, if no explicit tag is given.
|
||||
|
||||
When used by the `npm diff` command, this is the tag used to fetch the
|
||||
tarball that will be compared with the local files by default.
|
||||
|
||||
If used in the `npm publish` command, this is the tag that will be added to
|
||||
the package submitted to the registry.
|
||||
|
||||
|
||||
|
||||
#### `access`
|
||||
|
||||
* Default: 'public' for new packages, existing packages it will not change the
|
||||
current level
|
||||
* Type: null, "restricted", "public", or "private"
|
||||
|
||||
If you do not want your scoped package to be publicly viewable (and
|
||||
installable) set `--access=restricted`.
|
||||
|
||||
Unscoped packages cannot be set to `restricted`.
|
||||
|
||||
Note: This defaults to not changing the current access level for existing
|
||||
packages. Specifying a value of `restricted` or `public` during publish will
|
||||
change the access for an existing package the same way that `npm access set
|
||||
status` would.
|
||||
|
||||
The value `private` is an alias for `restricted`.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `provenance`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When publishing from a supported cloud CI/CD system, the package will be
|
||||
publicly linked to where it was built and published from.
|
||||
|
||||
This config cannot be used with: `provenance-file`
|
||||
|
||||
#### `provenance-file`
|
||||
|
||||
* Default: null
|
||||
* Type: Path
|
||||
|
||||
When publishing, the provenance bundle at the given path will be used.
|
||||
|
||||
This config cannot be used with: `provenance`
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm-packlist package](http://npm.im/npm-packlist)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm scope](/using-npm/scope)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
* [npm owner](/commands/npm-owner)
|
||||
* [npm deprecate](/commands/npm-deprecate)
|
||||
* [npm dist-tag](/commands/npm-dist-tag)
|
||||
* [npm pack](/commands/npm-pack)
|
||||
* [npm profile](/commands/npm-profile)
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
---
|
||||
title: npm-query
|
||||
section: 1
|
||||
description: Dependency selector query
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm query <selector>
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
The `npm query` command allows for usage of css selectors in order to retrieve an array of dependency objects.
|
||||
|
||||
### Piping npm query to other commands
|
||||
|
||||
```bash
|
||||
# find all dependencies with postinstall scripts & uninstall them
|
||||
npm query ":attr(scripts, [postinstall])" | jq 'map(.name)|join("\n")' -r | xargs -I {} npm uninstall {}
|
||||
|
||||
# find all git dependencies & explain who requires them
|
||||
npm query ":type(git)" | jq 'map(.name)' | xargs -I {} npm why {}
|
||||
```
|
||||
|
||||
### Extended Use Cases & Queries
|
||||
|
||||
```stylus
|
||||
// all deps
|
||||
*
|
||||
|
||||
// all direct deps
|
||||
:root > *
|
||||
|
||||
// direct production deps
|
||||
:root > .prod
|
||||
|
||||
// direct development deps
|
||||
:root > .dev
|
||||
|
||||
// any peer dep of a direct deps
|
||||
:root > * > .peer
|
||||
|
||||
// any workspace dep
|
||||
.workspace
|
||||
|
||||
// all workspaces that depend on another workspace
|
||||
.workspace > .workspace
|
||||
|
||||
// all workspaces that have peer deps
|
||||
.workspace:has(.peer)
|
||||
|
||||
// any dep named "lodash"
|
||||
// equivalent to [name="lodash"]
|
||||
#lodash
|
||||
|
||||
// any deps named "lodash" & within semver range ^"1.2.3"
|
||||
#lodash@^1.2.3
|
||||
// equivalent to...
|
||||
[name="lodash"]:semver(^1.2.3)
|
||||
|
||||
// get the hoisted node for a given semver range
|
||||
#lodash@^1.2.3:not(:deduped)
|
||||
|
||||
// querying deps with a specific version
|
||||
#lodash@2.1.5
|
||||
// equivalent to...
|
||||
[name="lodash"][version="2.1.5"]
|
||||
|
||||
// has any deps
|
||||
:has(*)
|
||||
|
||||
// deps with no other deps (ie. "leaf" nodes)
|
||||
:empty
|
||||
|
||||
// manually querying git dependencies
|
||||
[repository^=github:],
|
||||
[repository^=git:],
|
||||
[repository^=https://github.com],
|
||||
[repository^=http://github.com],
|
||||
[repository^=https://github.com],
|
||||
[repository^=+git:...]
|
||||
|
||||
// querying for all git dependencies
|
||||
:type(git)
|
||||
|
||||
// get production dependencies that aren't also dev deps
|
||||
.prod:not(.dev)
|
||||
|
||||
// get dependencies with specific licenses
|
||||
[license=MIT], [license=ISC]
|
||||
|
||||
// find all packages that have @ruyadorno as a contributor
|
||||
:attr(contributors, [email=ruyadorno@github.com])
|
||||
```
|
||||
|
||||
### Example Response Output
|
||||
|
||||
- an array of dependency objects is returned which can contain multiple copies of the same package which may or may not have been linked or deduped
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"name": "",
|
||||
"version": "",
|
||||
"description": "",
|
||||
"homepage": "",
|
||||
"bugs": {},
|
||||
"author": {},
|
||||
"license": {},
|
||||
"funding": {},
|
||||
"files": [],
|
||||
"main": "",
|
||||
"browser": "",
|
||||
"bin": {},
|
||||
"man": [],
|
||||
"directories": {},
|
||||
"repository": {},
|
||||
"scripts": {},
|
||||
"config": {},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": {},
|
||||
"peerDependencies": {},
|
||||
"peerDependenciesMeta": {},
|
||||
"engines": {},
|
||||
"os": [],
|
||||
"cpu": [],
|
||||
"workspaces": {},
|
||||
"keywords": [],
|
||||
...
|
||||
},
|
||||
...
|
||||
```
|
||||
|
||||
### Expecting a certain number of results
|
||||
|
||||
One common use of `npm query` is to make sure there is only one version of a certain dependency in your tree.
|
||||
This is especially common for ecosystems like that rely on `typescript` where having state split across two different but identically-named packages causes bugs.
|
||||
You can use the `--expect-results` or `--expect-result-count` in your setup to ensure that npm will exit with an exit code if your tree doesn't look like you want it to.
|
||||
|
||||
|
||||
```sh
|
||||
$ npm query '#react' --expect-result-count=1
|
||||
```
|
||||
|
||||
Perhaps you want to quickly check if there are any production dependencies that could be updated:
|
||||
|
||||
```sh
|
||||
$ npm query ':root>:outdated(in-range).prod' --no-expect-results
|
||||
```
|
||||
|
||||
### Package lock only mode
|
||||
|
||||
If package-lock-only is enabled, only the information in the package lock (or shrinkwrap) is loaded.
|
||||
This means that information from the package.json files of your dependencies will not be included in the result set (e.g. description, homepage, engines).
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `package-lock-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the current operation will only use the `package-lock.json`,
|
||||
ignoring `node_modules`.
|
||||
|
||||
For `update` this means only the `package-lock.json` will be updated,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
For `list` this means the output will be based on the tree described by the
|
||||
`package-lock.json`, rather than the contents of `node_modules`.
|
||||
|
||||
|
||||
|
||||
#### `expect-results`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Tells npm whether or not to expect results from the command. Can be either
|
||||
true (expect some results) or false (expect no results).
|
||||
|
||||
This config cannot be used with: `expect-result-count`
|
||||
|
||||
#### `expect-result-count`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Number
|
||||
|
||||
Tells to expect a specific number of results from the command.
|
||||
|
||||
This config cannot be used with: `expect-results`
|
||||
## See Also
|
||||
|
||||
* [dependency selectors](/using-npm/dependency-selectors)
|
||||
Generated
Vendored
+220
@@ -0,0 +1,220 @@
|
||||
---
|
||||
title: npm-rebuild
|
||||
section: 1
|
||||
description: Rebuild a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm rebuild [<package-spec>] ...]
|
||||
|
||||
alias: rb
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command does the following:
|
||||
|
||||
1. Execute lifecycle scripts (`preinstall`, `install`, `postinstall`, `prepare`)
|
||||
2. Links bins depending on whether bin links are enabled
|
||||
|
||||
This command is particularly useful in scenarios including but not limited to:
|
||||
|
||||
1. Installing a new version of **node.js**, where you need to recompile all your C++ add-ons with the updated binary.
|
||||
2. Installing with `--ignore-scripts` and `--no-bin-links`, to explicitly choose which packages to build and/or link bins.
|
||||
|
||||
If one or more package specs are provided, then only packages with a name and version matching one of the specifiers will be rebuilt.
|
||||
|
||||
Usually, you should not need to run `npm rebuild` as it is already done for you as part of npm install (unless you suppressed these steps with `--ignore-scripts` or `--no-bin-links`).
|
||||
|
||||
If there is a `binding.gyp` file in the root of your package, then npm will use a default install hook:
|
||||
|
||||
```
|
||||
"scripts": {
|
||||
"install": "node-gyp rebuild"
|
||||
}
|
||||
```
|
||||
|
||||
This default behavior is suppressed if the `package.json` has its own `install` or `preinstall` scripts.
|
||||
It is also suppressed if the package specifies `"gypfile": false`
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Comma-separated list of packages whose install-time lifecycle scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
dependencies) are allowed to run.
|
||||
|
||||
This setting is intended for one-off and global contexts: `npm exec`, `npx`,
|
||||
and `npm install -g`, where no project `package.json` is involved. For
|
||||
team-wide policy in a project, use the `allowScripts` field in
|
||||
`package.json` (which also supports explicit denials), or configure it in
|
||||
`.npmrc`. Passing `--allow-scripts` on the command line during a
|
||||
project-scoped `npm install`, `ci`, `update`, or `rebuild` is an error.
|
||||
|
||||
Each name is matched against a dependency's resolved identity, not against
|
||||
the package's self-reported name. `--ignore-scripts` and
|
||||
`--dangerously-allow-all-scripts` both override this setting.
|
||||
|
||||
|
||||
|
||||
#### `strict-allow-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, turn the install-script policy from a warning into a hard error:
|
||||
any dependency with install scripts not covered by `allowScripts` will fail
|
||||
the install instead of running with a notice.
|
||||
|
||||
Dependencies explicitly denied with `false` in `allowScripts` are always
|
||||
silently skipped; this setting only affects unreviewed entries.
|
||||
`--ignore-scripts` and `--dangerously-allow-all-scripts` both override this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `dangerously-allow-all-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, bypass the `allowScripts` policy entirely and run every
|
||||
dependency install script regardless of whether it was approved or denied.
|
||||
Intended as a migration escape hatch only; its use is strongly discouraged.
|
||||
`--ignore-scripts` still takes precedence over this setting.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm install](/commands/npm-install)
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
---
|
||||
title: npm-repo
|
||||
section: 1
|
||||
description: Open package repository page in the browser
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm repo [<pkgname> [<pkgname> ...]]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command tries to guess at the likely location of a package's repository URL, and then tries to open it using the [`--browser` config](/using-npm/config#browser) param.
|
||||
If no package name is provided, it will search for a `package.json` in the current folder and use the `repository` property.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `browser`
|
||||
|
||||
* Default: macOS: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
|
||||
* Type: null, Boolean, or String
|
||||
|
||||
The browser that is called by npm commands to open websites.
|
||||
|
||||
Set to `false` to suppress browser behavior and instead print urls to
|
||||
terminal.
|
||||
|
||||
Set to `true` to use default system URL opener.
|
||||
|
||||
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm docs](/commands/npm-docs)
|
||||
* [npm config](/commands/npm-config)
|
||||
Generated
Vendored
+68
@@ -0,0 +1,68 @@
|
||||
---
|
||||
title: npm-restart
|
||||
section: 1
|
||||
description: Restart a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm restart [-- <args>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This restarts a project.
|
||||
It is equivalent to running `npm run restart`.
|
||||
|
||||
If the current project has a `"restart"` script specified in `package.json`, then the following scripts will be run:
|
||||
|
||||
1. prerestart
|
||||
2. restart
|
||||
3. postrestart
|
||||
|
||||
If it does _not_ have a `"restart"` script specified, but it does have `stop` and/or `start` scripts, then the following scripts will be run:
|
||||
|
||||
1. prerestart
|
||||
2. prestop
|
||||
3. stop
|
||||
4. poststop
|
||||
6. prestart
|
||||
7. start
|
||||
8. poststart
|
||||
9. postrestart
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `script-shell`
|
||||
|
||||
* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
|
||||
* Type: null or String
|
||||
|
||||
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
|
||||
init <package-spec>` commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm test](/commands/npm-test)
|
||||
* [npm start](/commands/npm-start)
|
||||
* [npm stop](/commands/npm-stop)
|
||||
* [npm restart](/commands/npm-restart)
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: npm-root
|
||||
section: 1
|
||||
description: Display npm root
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm root
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Print the effective `node_modules` folder to standard out.
|
||||
|
||||
Useful for using npm in shell scripts that do things with the `node_modules` folder.
|
||||
For example:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
global_node_modules="$(npm root --global)"
|
||||
echo "Global packages installed in: ${global_node_modules}"
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm prefix](/commands/npm-prefix)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
---
|
||||
title: npm-run
|
||||
section: 1
|
||||
description: Run arbitrary package scripts
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm run <command> [-- <args>]
|
||||
|
||||
aliases: run-script, rum, urn
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This runs an arbitrary command from a package's `"scripts"` object.
|
||||
If no
|
||||
`"command"` is provided, it will list the available scripts.
|
||||
|
||||
`run[-script]` 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.
|
||||
|
||||
Any positional arguments are passed to the specified script.
|
||||
Use `--` to pass `-`-prefixed flags and options which would otherwise be parsed by npm.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npm run test -- --grep="pattern"
|
||||
```
|
||||
|
||||
The arguments will only be passed to the script specified after `npm run` and not to any `pre` or `post` script.
|
||||
|
||||
The `env` 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.
|
||||
|
||||
In addition to the shell's pre-existing `PATH`, `npm run` adds `node_modules/.bin` to the `PATH` provided to scripts.
|
||||
Any binaries provided by locally-installed dependencies can be used without the `node_modules/.bin` prefix.
|
||||
For example, if there is a `devDependency` on `tap` in your package, you should write:
|
||||
|
||||
```bash
|
||||
"scripts": {"test": "tap test/*.js"}
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```bash
|
||||
"scripts": {"test": "node_modules/.bin/tap test/*.js"}
|
||||
```
|
||||
|
||||
The actual shell your script is run within is platform dependent.
|
||||
By default, on Unix-like systems it is the `/bin/sh` command, on Windows it is `cmd.exe`.
|
||||
The actual shell referred to by `/bin/sh` also depends on the system.
|
||||
You can customize the shell with the [`script-shell` config](/using-npm/config#script-shell).
|
||||
|
||||
Scripts are run from the root of the package folder, regardless of what the current working directory is when `npm run` is called.
|
||||
If you want your script to use different behavior based on what subdirectory you're in, you can use the `INIT_CWD` environment variable, which holds the full path you were in when you ran `npm run`.
|
||||
|
||||
`npm run` sets the `NODE` environment variable to the `node` executable with which `npm` is executed.
|
||||
|
||||
If you try to run a script without having a `node_modules` directory and it fails, you will be given a warning to run `npm install`, just in case you've forgotten.
|
||||
|
||||
### Workspaces support
|
||||
|
||||
You may use the [`workspace`](/using-npm/config#workspace) or [`workspaces`](/using-npm/config#workspaces) configs in order to run an arbitrary command from a package's `"scripts"` object in the context of the specified workspaces.
|
||||
If no `"command"` is provided, it will list the available scripts for each of these configured workspaces.
|
||||
|
||||
Given a project with configured workspaces, e.g:
|
||||
|
||||
```
|
||||
.
|
||||
+-- package.json
|
||||
`-- packages
|
||||
+-- a
|
||||
| `-- package.json
|
||||
+-- b
|
||||
| `-- package.json
|
||||
`-- c
|
||||
`-- package.json
|
||||
```
|
||||
|
||||
Assuming the workspace configuration is properly set up at the root level `package.json` file.
|
||||
e.g:
|
||||
|
||||
```
|
||||
{
|
||||
"workspaces": [ "./packages/*" ]
|
||||
}
|
||||
```
|
||||
|
||||
And that each of the configured workspaces has a configured `test` script, we can run tests in all of them using the [`workspaces` config](/using-npm/config#workspaces):
|
||||
|
||||
```
|
||||
npm test --workspaces
|
||||
```
|
||||
|
||||
#### Filtering workspaces
|
||||
|
||||
It's also possible to run a script in a single workspace using the `workspace` config along with a name or directory path:
|
||||
|
||||
```
|
||||
npm test --workspace=a
|
||||
```
|
||||
|
||||
The `workspace` config can also be specified multiple times in order to run a specific script in the context of multiple workspaces.
|
||||
When defining values for the `workspace` config in the command line, it also possible to use `-w` as a shorthand, e.g:
|
||||
|
||||
```
|
||||
npm test -w a -w b
|
||||
```
|
||||
|
||||
This last command will run `test` in both `./packages/a` and `./packages/b` packages.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `if-present`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm will not exit with an error code when `run` is invoked for a
|
||||
script that isn't defined in the `scripts` section of `package.json`. This
|
||||
option can be used when it's desirable to optionally run a script when it's
|
||||
present and fail if the script fails. This is useful, for example, when
|
||||
running scripts that may only apply for some builds in an otherwise generic
|
||||
CI setup.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `script-shell`
|
||||
|
||||
* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
|
||||
* Type: null or String
|
||||
|
||||
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
|
||||
init <package-spec>` commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm test](/commands/npm-test)
|
||||
* [npm start](/commands/npm-start)
|
||||
* [npm restart](/commands/npm-restart)
|
||||
* [npm stop](/commands/npm-stop)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm workspaces](/using-npm/workspaces)
|
||||
+316
@@ -0,0 +1,316 @@
|
||||
---
|
||||
title: npm-sbom
|
||||
section: 1
|
||||
description: Generate a Software Bill of Materials (SBOM)
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm sbom
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
The `npm sbom` command generates a Software Bill of Materials (SBOM) listing the dependencies for the current project.
|
||||
SBOMs can be generated in either [SPDX](https://spdx.dev/) or [CycloneDX](https://cyclonedx.org/) format.
|
||||
|
||||
### Example CycloneDX SBOM
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
|
||||
"bomFormat": "CycloneDX",
|
||||
"specVersion": "1.5",
|
||||
"serialNumber": "urn:uuid:09f55116-97e1-49cf-b3b8-44d0207e7730",
|
||||
"version": 1,
|
||||
"metadata": {
|
||||
"timestamp": "2023-09-01T00:00:00.001Z",
|
||||
"lifecycles": [
|
||||
{
|
||||
"phase": "build"
|
||||
}
|
||||
],
|
||||
"tools": [
|
||||
{
|
||||
"vendor": "npm",
|
||||
"name": "cli",
|
||||
"version": "10.1.0"
|
||||
}
|
||||
],
|
||||
"component": {
|
||||
"bom-ref": "simple@1.0.0",
|
||||
"type": "library",
|
||||
"name": "simple",
|
||||
"version": "1.0.0",
|
||||
"scope": "required",
|
||||
"author": "John Doe",
|
||||
"description": "simple react app",
|
||||
"purl": "pkg:npm/simple@1.0.0",
|
||||
"properties": [
|
||||
{
|
||||
"name": "cdx:npm:package:path",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"externalReferences": [],
|
||||
"licenses": [
|
||||
{
|
||||
"license": {
|
||||
"id": "MIT"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"components": [
|
||||
{
|
||||
"bom-ref": "lodash@4.17.21",
|
||||
"type": "library",
|
||||
"name": "lodash",
|
||||
"version": "4.17.21",
|
||||
"scope": "required",
|
||||
"author": "John-David Dalton",
|
||||
"description": "Lodash modular utilities.",
|
||||
"purl": "pkg:npm/lodash@4.17.21",
|
||||
"properties": [
|
||||
{
|
||||
"name": "cdx:npm:package:path",
|
||||
"value": "node_modules/lodash"
|
||||
}
|
||||
],
|
||||
"externalReferences": [
|
||||
{
|
||||
"type": "distribution",
|
||||
"url": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git+https://github.com/lodash/lodash.git"
|
||||
},
|
||||
{
|
||||
"type": "website",
|
||||
"url": "https://lodash.com/"
|
||||
},
|
||||
{
|
||||
"type": "issue-tracker",
|
||||
"url": "https://github.com/lodash/lodash/issues"
|
||||
}
|
||||
],
|
||||
"hashes": [
|
||||
{
|
||||
"alg": "SHA-512",
|
||||
"content": "bf690311ee7b95e713ba568322e3533f2dd1cb880b189e99d4edef13592b81764daec43e2c54c61d5c558dc5cfb35ecb85b65519e74026ff17675b6f8f916f4a"
|
||||
}
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"license": {
|
||||
"id": "MIT"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{
|
||||
"ref": "simple@1.0.0",
|
||||
"dependsOn": [
|
||||
"lodash@4.17.21"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ref": "lodash@4.17.21",
|
||||
"dependsOn": []
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Example SPDX SBOM
|
||||
|
||||
```json
|
||||
{
|
||||
"spdxVersion": "SPDX-2.3",
|
||||
"dataLicense": "CC0-1.0",
|
||||
"SPDXID": "SPDXRef-DOCUMENT",
|
||||
"name": "simple@1.0.0",
|
||||
"documentNamespace": "http://spdx.org/spdxdocs/simple-1.0.0-bf81090e-8bbc-459d-bec9-abeb794e096a",
|
||||
"creationInfo": {
|
||||
"created": "2023-09-01T00:00:00.001Z",
|
||||
"creators": [
|
||||
"Tool: npm/cli-10.1.0"
|
||||
]
|
||||
},
|
||||
"documentDescribes": [
|
||||
"SPDXRef-Package-simple-1.0.0"
|
||||
],
|
||||
"packages": [
|
||||
{
|
||||
"name": "simple",
|
||||
"SPDXID": "SPDXRef-Package-simple-1.0.0",
|
||||
"versionInfo": "1.0.0",
|
||||
"packageFileName": "",
|
||||
"description": "simple react app",
|
||||
"primaryPackagePurpose": "LIBRARY",
|
||||
"downloadLocation": "NOASSERTION",
|
||||
"filesAnalyzed": false,
|
||||
"homepage": "NOASSERTION",
|
||||
"licenseDeclared": "MIT",
|
||||
"externalRefs": [
|
||||
{
|
||||
"referenceCategory": "PACKAGE-MANAGER",
|
||||
"referenceType": "purl",
|
||||
"referenceLocator": "pkg:npm/simple@1.0.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "lodash",
|
||||
"SPDXID": "SPDXRef-Package-lodash-4.17.21",
|
||||
"versionInfo": "4.17.21",
|
||||
"packageFileName": "node_modules/lodash",
|
||||
"description": "Lodash modular utilities.",
|
||||
"downloadLocation": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"filesAnalyzed": false,
|
||||
"homepage": "https://lodash.com/",
|
||||
"licenseDeclared": "MIT",
|
||||
"externalRefs": [
|
||||
{
|
||||
"referenceCategory": "PACKAGE-MANAGER",
|
||||
"referenceType": "purl",
|
||||
"referenceLocator": "pkg:npm/lodash@4.17.21"
|
||||
}
|
||||
],
|
||||
"checksums": [
|
||||
{
|
||||
"algorithm": "SHA512",
|
||||
"checksumValue": "bf690311ee7b95e713ba568322e3533f2dd1cb880b189e99d4edef13592b81764daec43e2c54c61d5c558dc5cfb35ecb85b65519e74026ff17675b6f8f916f4a"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"relationships": [
|
||||
{
|
||||
"spdxElementId": "SPDXRef-DOCUMENT",
|
||||
"relatedSpdxElement": "SPDXRef-Package-simple-1.0.0",
|
||||
"relationshipType": "DESCRIBES"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-Package-simple-1.0.0",
|
||||
"relatedSpdxElement": "SPDXRef-Package-lodash-4.17.21",
|
||||
"relationshipType": "DEPENDS_ON"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Package lock only mode
|
||||
|
||||
If package-lock-only is enabled, only the information in the package lock (or shrinkwrap) is loaded.
|
||||
This means that information from the package.json files of your dependencies will not be included in the result set (e.g.
|
||||
description, homepage, engines).
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `package-lock-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the current operation will only use the `package-lock.json`,
|
||||
ignoring `node_modules`.
|
||||
|
||||
For `update` this means only the `package-lock.json` will be updated,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
For `list` this means the output will be based on the tree described by the
|
||||
`package-lock.json`, rather than the contents of `node_modules`.
|
||||
|
||||
|
||||
|
||||
#### `sbom-format`
|
||||
|
||||
* Default: null
|
||||
* Type: "cyclonedx" or "spdx"
|
||||
|
||||
SBOM format to use when generating SBOMs.
|
||||
|
||||
|
||||
|
||||
#### `sbom-type`
|
||||
|
||||
* Default: "library"
|
||||
* Type: "library", "application", or "framework"
|
||||
|
||||
The type of package described by the generated SBOM. For SPDX, this is the
|
||||
value for the `primaryPackagePurpose` field. For CycloneDX, this is the
|
||||
value for the `type` field.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
## See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [dependency selectors](/using-npm/dependency-selectors)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [workspaces](/using-npm/workspaces)
|
||||
Generated
Vendored
+154
@@ -0,0 +1,154 @@
|
||||
---
|
||||
title: npm-search
|
||||
section: 1
|
||||
description: Search for packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm search <search term> [<search term> ...]
|
||||
|
||||
aliases: find, s, se
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Search the registry for packages matching the search terms.
|
||||
`npm search`
|
||||
performs a linear, incremental, lexically-ordered search through package metadata for all files in the registry.
|
||||
If your terminal has color support, it will further highlight the matches in the results.
|
||||
This can be disabled with the config item `color`
|
||||
|
||||
Additionally, using the `--searchopts` and `--searchexclude` options paired with more search terms will include and exclude further patterns.
|
||||
The main difference between `--searchopts` and the standard search terms is that the former does not highlight results in the output and you can use them more fine-grained filtering.
|
||||
Additionally, you can add both of these to your config to change default search filtering behavior.
|
||||
|
||||
Search also allows targeting of maintainers in search results, by prefixing their npm username with `=`.
|
||||
|
||||
If a term starts with `/`, then it's interpreted as a regular expression and supports standard JavaScript RegExp syntax.
|
||||
In this case search will ignore a trailing `/` . (Note you must escape or quote many regular expression characters in most shells.)
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `color`
|
||||
|
||||
* Default: true unless the NO_COLOR environ is set to something other than '0'
|
||||
* Type: "always" or Boolean
|
||||
|
||||
If false, never shows colors. If `"always"` then always shows colors. If
|
||||
true, then only prints color codes for tty file descriptors.
|
||||
|
||||
|
||||
|
||||
#### `parseable`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Output parseable results from commands that write to standard output. For
|
||||
`npm search`, this will be tab-separated table format.
|
||||
|
||||
|
||||
|
||||
#### `description`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Show the description in `npm search`
|
||||
|
||||
|
||||
|
||||
#### `searchlimit`
|
||||
|
||||
* Default: 20
|
||||
* Type: Number
|
||||
|
||||
Number of items to limit search results to. Will not apply at all to legacy
|
||||
searches.
|
||||
|
||||
|
||||
|
||||
#### `searchopts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String
|
||||
|
||||
Space-separated options that are always passed to search.
|
||||
|
||||
|
||||
|
||||
#### `searchexclude`
|
||||
|
||||
* Default: ""
|
||||
* Type: String
|
||||
|
||||
Space-separated options that limit the results from search.
|
||||
|
||||
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `prefer-online`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, staleness checks for cached data will be forced, making the CLI
|
||||
look for updates immediately even for fresh package data.
|
||||
|
||||
|
||||
|
||||
#### `prefer-offline`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, staleness checks for cached data will be bypassed, but missing data
|
||||
will be requested from the server. To force full offline mode, use
|
||||
`--offline`.
|
||||
|
||||
|
||||
|
||||
#### `offline`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Force offline mode: no network requests will be done during install. To
|
||||
allow the CLI to fill in missing cache data, see `--prefer-offline`.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm view](/commands/npm-view)
|
||||
* [npm cache](/commands/npm-cache)
|
||||
* https://npm.im/npm-registry-fetch
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: npm-set
|
||||
section: 1
|
||||
description: Set a value in the npm configuration
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm set <key>=<value> [<key>=<value> ...] (See `npm config`)
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Set a value in the npm configuration
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `location`
|
||||
|
||||
* Default: "user" unless `--global` is passed, which will also set this value
|
||||
to "global"
|
||||
* Type: "global", "user", or "project"
|
||||
|
||||
When passed to `npm config` this refers to which config file to use.
|
||||
|
||||
When set to "global" mode, packages are installed into the `prefix` folder
|
||||
instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm help config](/commands/npm-config)
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: npm-shrinkwrap
|
||||
section: 1
|
||||
description: Lock down dependency versions for publication
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm shrinkwrap
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
This command repurposes `package-lock.json` into a publishable `npm-shrinkwrap.json` or simply creates a new one.
|
||||
The file created and updated by this command will then take precedence over any other existing or future `package-lock.json` files.
|
||||
For a detailed explanation of the design and purpose of package locks in npm, see [package-lock-json](/configuring-npm/package-lock-json).
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [package-lock.json](/configuring-npm/package-lock-json)
|
||||
* [npm-shrinkwrap.json](/configuring-npm/npm-shrinkwrap-json)
|
||||
* [npm ls](/commands/npm-ls)
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
---
|
||||
title: npm-stage
|
||||
section: 1
|
||||
description: Stage packages for publishing
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm stage
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Staged publishing allows package maintainers to require proof-of-presence
|
||||
for all publishes. Proof-of-presence is where a human is involved,
|
||||
interjects, and provides authentication (2FA) during an action — in this
|
||||
case, publishing an npm package.
|
||||
|
||||
Typically when maintainers use automated workflows to publish,
|
||||
proof-of-presence is lacking as there's no convenient way to interject the
|
||||
process and provide 2FA, as is the case for publishing with a granular
|
||||
access token with bypass and the trusted publishing flow. Staged publishing
|
||||
allows users to have their automated workflows stage a package without a 2FA
|
||||
prompt, deferring the act of 2FA, allowing the maintainer to approve the
|
||||
staged package and publish at a later point.
|
||||
|
||||
The `npm stage publish` command packs the current working directory and
|
||||
places that version of the package into the registry in a state where it's
|
||||
not available for public access, allowing maintainers to approve the package
|
||||
at a later point in time. The act of staging does not prompt for 2FA and can be done with any token
|
||||
type, the act of approving will.
|
||||
|
||||
Key behaviors:
|
||||
|
||||
* Staged packages share the same semver version unique index as published
|
||||
packages — you cannot publish a version that already exists as a staged
|
||||
version for that package.
|
||||
* You can still publish packages normally while you have staged packages
|
||||
pending.
|
||||
* You can stage multiple versions of the same package.
|
||||
* `npm stage publish` has parity with `npm publish` and will respect
|
||||
`"private": true` in `package.json`, refusing to stage the package.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before using `npm stage` commands, ensure the following requirements are met:
|
||||
|
||||
* **Write permissions on the package:** You must have write access to the
|
||||
package you're configuring.
|
||||
* **Package must exist:** The package you're configuring must already exist
|
||||
on the npm registry.
|
||||
* **2FA enabled on your account:** Commands that require 2FA will prompt you
|
||||
to authenticate. If you don't already have 2FA enabled on your account,
|
||||
you must enable it before using these commands.
|
||||
|
||||
### Subcommands
|
||||
|
||||
* `npm stage publish [<package-spec>]` - Stage a package for publishing
|
||||
* `npm stage list [<package-spec>]` - List all staged package versions
|
||||
* `npm stage view <stage-id>` - View details of a specific staged package
|
||||
* `npm stage approve <stage-id>` - Approve a staged package for publishing
|
||||
* `npm stage reject <stage-id>` - Reject a staged package
|
||||
* `npm stage download <stage-id>` - Download the tarball for inspection
|
||||
|
||||
### 2FA Requirements by Subcommand
|
||||
|
||||
| Command | Requires 2FA | Notes |
|
||||
| --- | --- | --- |
|
||||
| `npm stage publish` | No | Designed for automated workflows; defers 2FA to approval |
|
||||
| `npm stage list` | No | View staged packages |
|
||||
| `npm stage view` | No | View staged package details |
|
||||
| `npm stage approve` | Yes | Prompts for 2FA to publish the staged package |
|
||||
| `npm stage reject` | Yes | Prompts for 2FA to permanently remove the staged package |
|
||||
| `npm stage download` | No | Downloads the tarball for local inspection |
|
||||
|
||||
### Tag Behavior
|
||||
|
||||
The `--tag` flag follows the same logic as `npm publish`. If no tag is
|
||||
provided, the `latest` tag is used by default. For pre-release versions
|
||||
(e.g., `1.0.0-beta.1`) and non-latest semver versions, the tag must be
|
||||
explicitly provided — otherwise the CLI will error, just as `npm publish`
|
||||
would.
|
||||
|
||||
The tag is an immutable property of the staged package. Once a package is
|
||||
staged with a given tag, the tag cannot be changed. If you need to stage the
|
||||
same version with a different tag, you must first reject the existing staged
|
||||
package using `npm stage reject` and then re-stage it with the desired tag.
|
||||
|
||||
### Token Behavior
|
||||
|
||||
The key difference with staged publishing is that `npm stage publish` never
|
||||
requires a 2FA prompt, regardless of token type. This is what makes it
|
||||
suitable for automated workflows. The goal of `npm stage publish` is
|
||||
deferring proof-of-presence to a later point in time.
|
||||
|
||||
| Token Type | `npm stage publish` | `npm publish` |
|
||||
| --- | --- | --- |
|
||||
| GAT with bypass | Can stage | Can publish (if allowed by package publishing access) |
|
||||
| GAT without bypass | Can stage | 2FA prompt (if allowed by package publishing access) |
|
||||
| Session token | Can stage | 2FA prompt |
|
||||
| Trust token (OIDC) | Can stage (if allowed) | Can publish (if allowed) |
|
||||
|
||||
### Trust Relationship Permissions
|
||||
|
||||
With staged publishing, trust relationships now support granular command
|
||||
permissions. Shortlived tokens issued through trust relationships can only be
|
||||
used with `npm stage publish` and `npm publish`. Shortlived tokens cannot run
|
||||
`npm stage` subcommands.
|
||||
|
||||
`npm trust <provider>` supports `--allow-publish` and `--allow-stage-publish`
|
||||
to control which commands are available through each trust relationship.
|
||||
|
||||
### Best Practices
|
||||
|
||||
**Note:** The addition of staged publishing does not make your account or org
|
||||
more secure. Maintainers must still use the best practices listed below.
|
||||
|
||||
1. **Delete Granular Access Tokens (GAT) with bypass 2FA enabled.**
|
||||
Now with staged publishing, we've eliminated the need for a GAT token
|
||||
that can bypass 2FA. We encourage you to delete all your tokens with
|
||||
bypass enabled and switch to using a trust relationship in your automated
|
||||
workflows, or create a GAT without bypass and use `npm stage publish`.
|
||||
|
||||
2. **Disallow tokens from publishing at the package level.**
|
||||
All packages have their own access controls under "package access"
|
||||
allowing packages to be published with bypass tokens, which is no longer
|
||||
a necessity. We encourage you to select "Require two-factor
|
||||
authentication and disallow tokens (recommended)" for all your packages
|
||||
on the package access page.
|
||||
|
||||
3. **Configure trust relationship permissions to prevent `npm publish`.**
|
||||
We encourage you to only enable `npm stage publish` on your trust
|
||||
relationships and disable `npm publish`.
|
||||
|
||||
### Configuration
|
||||
|
||||
### `npm stage publish`
|
||||
|
||||
Stage a package for publishing, deferring proof-of-presence (2FA) to a later point in time
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm stage publish <package-spec>
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--tag` | "latest" | String | If you ask npm to install a package and don't tell it a specific version, then it will install the specified tag. It is the tag added to the package@version specified in the `npm dist-tag add` command, if no explicit tag is given. When used by the `npm diff` command, this is the tag used to fetch the tarball that will be compared with the local files by default. If used in the `npm publish` command, this is the tag that will be added to the package submitted to the registry. |
|
||||
| `--access` | 'public' for new packages, existing packages it will not change the current level | null, "restricted", "public", or "private" | If you do not want your scoped package to be publicly viewable (and installable) set `--access=restricted`. Unscoped packages cannot be set to `restricted`. Note: This defaults to not changing the current access level for existing packages. Specifying a value of `restricted` or `public` during publish will change the access for an existing package the same way that `npm access set status` would. The value `private` is an alias for `restricted`. |
|
||||
| `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
|
||||
| `--otp` | null | null or String | This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with `npm access`. If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one. |
|
||||
| `--workspace`, `-w` | | String (can be set multiple times) | Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option. Valid values for the `workspace` config are either: * Workspace names * Path to a workspace directory * Path to a parent workspace directory (will result in selecting all workspaces within that folder) When set for the `npm init` command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project. |
|
||||
| `--workspaces` | null | null or Boolean | Set to true to run the command in the context of **all** configured workspaces. Explicitly setting this to false will cause commands like `install` to ignore workspaces altogether. When not set explicitly: - Commands that operate on the `node_modules` tree (install, update, etc.) will link workspaces into the `node_modules` folder. - Commands that do other things (test, exec, publish, etc.) will operate on the root project, _unless_ one or more workspaces are specified in the `workspace` config. |
|
||||
| `--include-workspace-root` | false | Boolean | Include the workspace root when workspaces are enabled for a command. When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. |
|
||||
| `--provenance` | false | Boolean | When publishing from a supported cloud CI/CD system, the package will be publicly linked to where it was built and published from. |
|
||||
|
||||
### `npm stage list`
|
||||
|
||||
List all staged package versions
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm stage list [<package-spec>]
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
|
||||
### `npm stage view`
|
||||
|
||||
View details of a specific staged package
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm stage view <stage-id>
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
|
||||
### `npm stage approve`
|
||||
|
||||
Approve a staged package, publishing it to the npm registry
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm stage approve <stage-id>
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--otp` | null | null or String | This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with `npm access`. If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
|
||||
### `npm stage reject`
|
||||
|
||||
Reject a staged package, removing it from the registry
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm stage reject <stage-id>
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--otp` | null | null or String | This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with `npm access`. If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
|
||||
### `npm stage download`
|
||||
|
||||
Download the tarball of a staged package for inspection
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm stage download <stage-id>
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm unpublish](/commands/npm-unpublish)
|
||||
* [npm trust](/commands/npm-trust)
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
---
|
||||
title: npm-star
|
||||
section: 1
|
||||
description: Mark your favorite packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm star [<package-spec>...]
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
"Starring" a package means that you have some interest in it.
|
||||
It's a vaguely positive way to show that you care.
|
||||
|
||||
It's a boolean thing.
|
||||
Starring repeatedly has no additional effect.
|
||||
|
||||
### More
|
||||
|
||||
There's also these extra commands to help you manage your favorite packages:
|
||||
|
||||
#### Unstar
|
||||
|
||||
You can also "unstar" a package using [`npm unstar`](/commands/npm-unstar)
|
||||
|
||||
"Unstarring" is the same thing, but in reverse.
|
||||
|
||||
#### Listing stars
|
||||
|
||||
You can see all your starred packages using [`npm stars`](/commands/npm-stars)
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `unicode`
|
||||
|
||||
* Default: false on windows, true on mac/unix systems with a unicode locale,
|
||||
as defined by the `LC_ALL`, `LC_CTYPE`, or `LANG` environment variables.
|
||||
* Type: Boolean
|
||||
|
||||
When set to true, npm uses unicode characters in the tree output. When
|
||||
false, it uses ascii characters instead of unicode glyphs.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm unstar](/commands/npm-unstar)
|
||||
* [npm stars](/commands/npm-stars)
|
||||
* [npm view](/commands/npm-view)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: npm-stars
|
||||
section: 1
|
||||
description: View packages marked as favorites
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm stars [<user>]
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
If you have starred a lot of neat things and want to find them again quickly this command lets you do just that.
|
||||
|
||||
You may also want to see your friend's favorite packages, in this case you will most certainly enjoy this command.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm star](/commands/npm-star)
|
||||
* [npm unstar](/commands/npm-unstar)
|
||||
* [npm view](/commands/npm-view)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
---
|
||||
title: npm-start
|
||||
section: 1
|
||||
description: Start a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm start [-- <args>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This runs a predefined command specified in the `"start"` property of a package's `"scripts"` object.
|
||||
|
||||
If the `"scripts"` object does not define a `"start"` property, npm will run `node server.js`.
|
||||
|
||||
Note that this is different from the default node behavior of running the file specified in a package's `"main"` attribute when evoking with `node .`
|
||||
|
||||
As of [`npm@2.0.0`](https://blog.npmjs.org/post/98131109725/npm-2-0-0), you can use custom arguments when executing scripts.
|
||||
Refer to [`npm run`](/commands/npm-run) for more details.
|
||||
|
||||
### Example
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"start": "node foo.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
npm start
|
||||
|
||||
> npm@x.x.x start
|
||||
> node foo.js
|
||||
|
||||
(foo.js output would be here)
|
||||
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `script-shell`
|
||||
|
||||
* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
|
||||
* Type: null or String
|
||||
|
||||
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
|
||||
init <package-spec>` commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm test](/commands/npm-test)
|
||||
* [npm restart](/commands/npm-restart)
|
||||
* [npm stop](/commands/npm-stop)
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: npm-stop
|
||||
section: 1
|
||||
description: Stop a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm stop [-- <args>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This runs a predefined command specified in the "stop" property of a package's "scripts" object.
|
||||
|
||||
Unlike with [npm start](/commands/npm-start), there is no default script that will run if the `"stop"` property is not defined.
|
||||
|
||||
### Example
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"stop": "node bar.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
npm stop
|
||||
|
||||
> npm@x.x.x stop
|
||||
> node bar.js
|
||||
|
||||
(bar.js output would be here)
|
||||
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `script-shell`
|
||||
|
||||
* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
|
||||
* Type: null or String
|
||||
|
||||
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
|
||||
init <package-spec>` commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm test](/commands/npm-test)
|
||||
* [npm start](/commands/npm-start)
|
||||
* [npm restart](/commands/npm-restart)
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
---
|
||||
title: npm-team
|
||||
section: 1
|
||||
description: Manage organization teams and team memberships
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm team create <scope:team> [--otp <otpcode>]
|
||||
npm team destroy <scope:team> [--otp <otpcode>]
|
||||
npm team add <scope:team> <user> [--otp <otpcode>]
|
||||
npm team rm <scope:team> <user> [--otp <otpcode>]
|
||||
npm team ls <scope>|<scope:team>
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Used to manage teams in organizations, and change team memberships.
|
||||
Does not handle permissions for packages.
|
||||
|
||||
Teams must always be fully qualified with the organization/scope they belong to when operating on them, separated by a colon (`:`).
|
||||
That is, if you have a `newteam` team in an `org` organization, you must always refer to that team as `@org:newteam` in these commands.
|
||||
|
||||
If you have two-factor authentication enabled in `auth-and-writes` mode, then you can provide a code from your authenticator with `[--otp <otpcode>]`.
|
||||
If you don't include this then you will be taken through a second factor flow based on your `authtype`.
|
||||
|
||||
* create / destroy:
|
||||
Create a new team, or destroy an existing one.
|
||||
Note: You cannot remove the `developers` team, [learn more.](https://docs.npmjs.com/about-developers-team)
|
||||
|
||||
Here's how to create a new team `newteam` under the `org` org:
|
||||
|
||||
```bash
|
||||
npm team create @org:newteam
|
||||
```
|
||||
|
||||
You should see a confirming message such as: `+@org:newteam` once the new team has been created.
|
||||
|
||||
* add:
|
||||
Add a user to an existing team.
|
||||
|
||||
Adding a new user `username` to a team named `newteam` under the `org` org:
|
||||
|
||||
```bash
|
||||
npm team add @org:newteam username
|
||||
```
|
||||
|
||||
On success, you should see a message: `username added to @org:newteam`
|
||||
|
||||
* rm:
|
||||
Using `npm team rm` you can also remove users from a team they belong to.
|
||||
|
||||
Here's an example removing user `username` from `newteam` team in `org` organization:
|
||||
|
||||
```bash
|
||||
npm team rm @org:newteam username
|
||||
```
|
||||
|
||||
Once the user is removed a confirmation message is displayed:
|
||||
`username removed from @org:newteam`
|
||||
|
||||
* 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.
|
||||
|
||||
Here's an example of how to list all teams from an org named `org`:
|
||||
|
||||
```bash
|
||||
npm team ls @org
|
||||
```
|
||||
|
||||
Example listing all members of a team named `newteam`:
|
||||
|
||||
```bash
|
||||
npm team ls @org:newteam
|
||||
```
|
||||
|
||||
### Details
|
||||
|
||||
`npm team` always operates directly on the current registry, configurable from the command line using `--registry=<registry url>`.
|
||||
|
||||
You must be a *team admin* to create teams and manage team membership, under the given organization.
|
||||
Listing teams and team memberships may be done by any member of the organization.
|
||||
|
||||
Organization creation and management of team admins and *organization* members is done through the website, not the npm CLI.
|
||||
|
||||
To use teams to manage permissions on packages belonging to your organization, use the `npm access` command to grant or revoke the appropriate permissions.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `parseable`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Output parseable results from commands that write to standard output. For
|
||||
`npm search`, this will be tab-separated table format.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm access](/commands/npm-access)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm registry](/using-npm/registry)
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
---
|
||||
title: npm-test
|
||||
section: 1
|
||||
description: Test a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm test [-- <args>]
|
||||
|
||||
aliases: tst, t
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This runs a predefined command specified in the `"test"` property of a package's `"scripts"` object.
|
||||
|
||||
### Example
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
npm test
|
||||
> npm@x.x.x test
|
||||
> node test.js
|
||||
|
||||
(test.js output would be here)
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `script-shell`
|
||||
|
||||
* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
|
||||
* Type: null or String
|
||||
|
||||
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
|
||||
init <package-spec>` commands.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm start](/commands/npm-start)
|
||||
* [npm restart](/commands/npm-restart)
|
||||
* [npm stop](/commands/npm-stop)
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
---
|
||||
title: npm-token
|
||||
section: 1
|
||||
description: Manage your authentication tokens
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm token list
|
||||
npm token revoke <id|token>
|
||||
npm token create
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
This lets you list, create and revoke authentication tokens.
|
||||
|
||||
#### Listing tokens
|
||||
|
||||
When listing tokens, an abbreviated token will be displayed. For security purposes the full token is not displayed.
|
||||
|
||||
#### Generating tokens
|
||||
|
||||
When generating tokens, you will be prompted you for your password and, if you have two-factor authentication enabled, an otp.
|
||||
|
||||
Please refer to the [docs website](https://docs.npmjs.com/creating-and-viewing-access-tokens) for more information on generating tokens for CI/CD.
|
||||
|
||||
#### Revoking tokens
|
||||
|
||||
When revoking a token, you can use the full token (e.g. what you get back from `npm token create`, or as can be found in an `.npmrc` file), or a truncated id. If the given truncated id is not distinct enough to differentiate between multiple existing tokens, you will need to use enough of the id to allow npm to distinguish between them. Full token ids can be found on the [npm website](https://www.npmjs.com), or in the `--parseable` or `--json` output of `npm token list`. This command will NOT accept the truncated token found in the normal `npm token list` output.
|
||||
|
||||
A revoked token will immediately be removed from the registry and you will no longer be able to use it.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `name`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, this sets the
|
||||
name/description for the token.
|
||||
|
||||
|
||||
|
||||
#### `token-description`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Description text for the token when using `npm token create`.
|
||||
|
||||
|
||||
|
||||
#### `expires`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Number
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, this sets the
|
||||
expiration in days. If not specified, the server will determine the default
|
||||
expiration.
|
||||
|
||||
|
||||
|
||||
#### `packages`
|
||||
|
||||
* Default:
|
||||
* Type: null or String (can be set multiple times)
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, this limits
|
||||
the token access to specific packages.
|
||||
|
||||
|
||||
|
||||
#### `packages-all`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, grants the
|
||||
token access to all packages instead of limiting to specific packages.
|
||||
|
||||
|
||||
|
||||
#### `scopes`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String (can be set multiple times)
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, this limits
|
||||
the token access to specific scopes. Provide a scope name (with or without @
|
||||
prefix).
|
||||
|
||||
|
||||
|
||||
#### `orgs`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String (can be set multiple times)
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, this limits
|
||||
the token access to specific organizations.
|
||||
|
||||
|
||||
|
||||
#### `packages-and-scopes-permission`
|
||||
|
||||
* Default: null
|
||||
* Type: null, "read-only", "read-write", or "no-access"
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, sets the
|
||||
permission level for packages and scopes. Options are "read-only",
|
||||
"read-write", or "no-access".
|
||||
|
||||
|
||||
|
||||
#### `orgs-permission`
|
||||
|
||||
* Default: null
|
||||
* Type: null, "read-only", "read-write", or "no-access"
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, sets the
|
||||
permission level for organizations. Options are "read-only", "read-write",
|
||||
or "no-access".
|
||||
|
||||
|
||||
|
||||
#### `cidr`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String (can be set multiple times)
|
||||
|
||||
This is a list of CIDR address to be used when configuring limited access
|
||||
tokens with the `npm token create` command.
|
||||
|
||||
|
||||
|
||||
#### `bypass-2fa`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When creating a Granular Access Token with `npm token create`, setting this
|
||||
to true will allow the token to bypass two-factor authentication. This is
|
||||
useful for automation and CI/CD workflows.
|
||||
|
||||
|
||||
|
||||
#### `password`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
Password for authentication. Can be provided via command line when creating
|
||||
tokens, though it's generally safer to be prompted for it.
|
||||
|
||||
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `read-only`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
This is used to mark a token as unable to publish when configuring limited
|
||||
access tokens with the `npm token create` command.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm owner](/commands/npm-owner)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
* [npm profile](/commands/npm-profile)
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
---
|
||||
title: npm-trust
|
||||
section: 1
|
||||
description: Manage trusted publishing relationships between packages and CI/CD providers
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before using npm trust commands, ensure the following requirements are met:
|
||||
|
||||
* **npm version**: `npm@11.10.0` or above is required. Use `npm install -g npm@^11.10.0` to update if needed.
|
||||
* **Write permissions on the package**: You must have write access to the package you're configuring.
|
||||
* **2FA enabled on account**: Two-factor authentication must be enabled at the account level. Even if it's not currently enabled, you must enable it to use trust commands.
|
||||
* **Supported authentication methods**: Granular Access Tokens (GAT) with the bypass 2FA option are not supported. Legacy basic auth (username and password) credentials will not work for trust commands or endpoints.
|
||||
* **Package must exist**: The package you're configuring must already exist on the npm registry.
|
||||
|
||||
### Description
|
||||
|
||||
Configure trust relationships between npm packages and CI/CD providers using OpenID Connect (OIDC). This is the command-line equivalent of managing trusted publisher configurations on the npm website.
|
||||
|
||||
For a comprehensive overview of trusted publishing, see the [npm trusted publishers documentation](https://docs.npmjs.com/trusted-publishers).
|
||||
|
||||
The `[package]` argument specifies the package name. If omitted, npm will use the name from the `package.json` in the current directory.
|
||||
|
||||
Each trust relationship has its own set of configuration options and flags based on the OIDC claims provided by that provider. OIDC claims come from the CI/CD provider and include information such as repository name, workflow file, or environment. Since each provider's claims differ, the available flags and configuration keys are not universal—npm matches the claims supported by each provider's OIDC configuration. For specific details on which claims and flags are supported for a given provider, use `npm trust <provider> --help`.
|
||||
|
||||
### Permissions
|
||||
|
||||
When creating a trust relationship, you must specify at least one permission flag to indicate which operations the trusted publisher is allowed to perform:
|
||||
|
||||
* `--allow-publish`: Allows the trusted publisher to run `npm publish` for the package.
|
||||
* `--allow-stage-publish`: Allows the trusted publisher to run `npm stage` for the package. The alias `--allow-staged-publish` is also accepted.
|
||||
|
||||
At least one of these flags is required when creating a trust configuration. You can specify both to grant both permissions.
|
||||
|
||||
### Provider Options
|
||||
|
||||
The required options depend on the CI/CD provider you're configuring. Detailed information about each option is available in the [managing trusted publisher configurations](https://docs.npmjs.com/trusted-publishers#managing-trusted-publisher-configurations) section of the npm documentation. If a provider is repository-based and the option is not provided, npm will use the `repository.url` field from your `package.json`, if available.
|
||||
|
||||
Currently, the registry only supports one configuration per package. If you attempt to create a new trust relationship when one already exists, it will result in an error. To replace an existing configuration:
|
||||
|
||||
1. Use `npm trust list [package]` to view the ID of the existing trusted publisher
|
||||
2. Use `npm trust revoke --id <id> [package]` to remove the existing configuration
|
||||
3. Then create your new trust relationship
|
||||
|
||||
### Bulk Usage
|
||||
|
||||
For maintainers managing a large number of packages, you can configure trusted publishing in bulk using bash scripting. Create a loop that iterates through package names and their corresponding configuration details, executing the `npm trust <provider>` command with the `--yes` flag for each package.
|
||||
|
||||
The first request will require two-factor authentication. During two-factor authentication, you'll see an option on the npm website to skip two-factor authentication for the next 5 minutes. Enabling this option will allow subsequent `npm trust <provider>` commands to proceed without two-factor authentication, streamlining the bulk configuration process.
|
||||
|
||||
We recommend adding a 2-second sleep between each call to avoid rate limiting. With this approach, you can configure approximately 80 packages within the 5-minute two-factor authentication skip window.
|
||||
|
||||
### Configuration
|
||||
|
||||
### `npm trust github`
|
||||
|
||||
Create a trusted relationship between a package and GitHub Actions
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm trust github [package] --file [--repo|--repository] [--env|--environment] [--allow-publish] [--allow-stage-publish] [-y|--yes]
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--file` | null | String (required) | Name of workflow file within a repositories .GitHub folder (must end in yaml, yml) |
|
||||
| `--repository`, `--repo` | null | String | Name of the repository in the format owner/repo |
|
||||
| `--environment`, `--env` | null | String | CI environment name |
|
||||
| `--allow-publish` | false | Boolean | Allow npm publish for this trusted publisher configuration |
|
||||
| `--allow-stage-publish`, `--allow-staged-publish` | false | Boolean | Allow npm stage publish for this trusted publisher configuration |
|
||||
| `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
|
||||
| `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
| `--yes`, `-y` | null | null or Boolean | Automatically answer "yes" to any prompts that npm might print on the command line. |
|
||||
|
||||
### `npm trust gitlab`
|
||||
|
||||
Create a trusted relationship between a package and GitLab CI/CD
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm trust gitlab [package] --file [--project|--repo|--repository] [--env|--environment] [--allow-publish] [--allow-stage-publish] [-y|--yes]
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--file` | null | String (required) | Name of pipeline file (e.g., .gitlab-ci.yml) |
|
||||
| `--project` | null | String | Name of the project in the format group/project or group/subgroup/project |
|
||||
| `--environment`, `--env` | null | String | CI environment name |
|
||||
| `--allow-publish` | false | Boolean | Allow npm publish for this trusted publisher configuration |
|
||||
| `--allow-stage-publish`, `--allow-staged-publish` | false | Boolean | Allow npm stage publish for this trusted publisher configuration |
|
||||
| `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
|
||||
| `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
| `--yes`, `-y` | null | null or Boolean | Automatically answer "yes" to any prompts that npm might print on the command line. |
|
||||
|
||||
### `npm trust circleci`
|
||||
|
||||
Create a trusted relationship between a package and CircleCI
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm trust circleci [package] --org-id <uuid> --project-id <uuid> --pipeline-definition-id <uuid> --vcs-origin <origin> [--context-id <uuid>...] [--allow-publish] [--allow-stage-publish] [-y|--yes]
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--org-id` | null | String (required) | CircleCI organization UUID |
|
||||
| `--project-id` | null | String (required) | CircleCI project UUID |
|
||||
| `--pipeline-definition-id` | null | String (required) | CircleCI pipeline definition UUID |
|
||||
| `--vcs-origin` | null | String (required) | CircleCI repository origin in format 'provider/owner/repo' |
|
||||
| `--context-id` | null | null or String (can be set multiple times) | CircleCI context UUID to match |
|
||||
| `--allow-publish` | false | Boolean | Allow npm publish for this trusted publisher configuration |
|
||||
| `--allow-stage-publish`, `--allow-staged-publish` | false | Boolean | Allow npm stage publish for this trusted publisher configuration |
|
||||
| `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
|
||||
| `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
| `--yes`, `-y` | null | null or Boolean | Automatically answer "yes" to any prompts that npm might print on the command line. |
|
||||
|
||||
### `npm trust list`
|
||||
|
||||
List trusted relationships for a package
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm trust list [package]
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. * In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
|
||||
### `npm trust revoke`
|
||||
|
||||
Revoke a trusted relationship for a package
|
||||
|
||||
#### Synopsis
|
||||
|
||||
```bash
|
||||
npm trust revoke [package] --id=<trust-id>
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Default | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `--id` | null | String (required) | ID of the trusted relationship to revoke |
|
||||
| `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
|
||||
| `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm token](/commands/npm-token)
|
||||
* [npm access](/commands/npm-access)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm registry](/using-npm/registry)
|
||||
Generated
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: npm-undeprecate
|
||||
section: 1
|
||||
description: Undeprecate a version of a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm undeprecate <package-spec>
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
This command will update the npm registry entry for a package, removing any deprecation warnings that currently exist.
|
||||
|
||||
It works in the same way as [npm deprecate](/commands/npm-deprecate), except that this command removes deprecation warnings instead of adding them.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm deprecate](/commands/npm-deprecate)
|
||||
Generated
Vendored
+151
@@ -0,0 +1,151 @@
|
||||
---
|
||||
title: npm-uninstall
|
||||
section: 1
|
||||
description: Remove a package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm uninstall [<@scope>/]<pkg>...
|
||||
|
||||
aliases: unlink, remove, rm, r, un
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This uninstalls a package, completely removing everything npm installed on its behalf.
|
||||
|
||||
It also removes the package from the `dependencies`, `devDependencies`,
|
||||
`optionalDependencies`, and `peerDependencies` objects in your `package.json`.
|
||||
|
||||
Further, if you have an `npm-shrinkwrap.json` or `package-lock.json`, npm will update those files as well.
|
||||
|
||||
`--no-save` will tell npm not to remove the package from your `package.json`, `npm-shrinkwrap.json`, or `package-lock.json` files.
|
||||
|
||||
`--save` or `-S` will tell npm to remove the package from your `package.json`, `npm-shrinkwrap.json`, and `package-lock.json` files.
|
||||
This is the default, but you may need to use this if you have for instance `save=false` in your `npmrc` file
|
||||
|
||||
In global mode (ie, with `-g` or `--global` appended to the command), it uninstalls the current package context as a global package.
|
||||
`--no-save` is ignored in this case.
|
||||
|
||||
Scope is optional and follows the usual rules for [`scope`](/using-npm/scope).
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
npm uninstall sax
|
||||
```
|
||||
|
||||
`sax` will no longer be in your `package.json`, `npm-shrinkwrap.json`, or `package-lock.json` files.
|
||||
|
||||
```bash
|
||||
npm uninstall lodash --no-save
|
||||
```
|
||||
|
||||
`lodash` will not be removed from your `package.json`,
|
||||
`npm-shrinkwrap.json`, or `package-lock.json` files.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `save`
|
||||
|
||||
* Default: `true` unless when using `npm update` where it defaults to `false`
|
||||
* Type: Boolean
|
||||
|
||||
Save installed packages to a `package.json` file as dependencies.
|
||||
|
||||
When used with the `npm rm` command, removes the dependency from
|
||||
`package.json`.
|
||||
|
||||
Will also prevent writing to `package-lock.json` if set to `false`.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm prune](/commands/npm-prune)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
Generated
Vendored
+126
@@ -0,0 +1,126 @@
|
||||
---
|
||||
title: npm-unpublish
|
||||
section: 1
|
||||
description: Remove a package from the registry
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm unpublish [<package-spec>]
|
||||
```
|
||||
|
||||
To learn more about how the npm registry treats unpublish, see our [unpublish policies](https://docs.npmjs.com/policies/unpublish).
|
||||
|
||||
### Warning
|
||||
|
||||
Consider using the [`deprecate`](/commands/npm-deprecate) command instead, if your intent is to encourage users to upgrade, or if you no longer want to maintain a package.
|
||||
|
||||
### Description
|
||||
|
||||
This removes a package version from the registry, deleting its entry and removing the tarball.
|
||||
|
||||
The npm registry will return an error if you are not [logged in](/commands/npm-adduser).
|
||||
|
||||
If you do not specify a package name at all, the name and version to be unpublished will be pulled from the project in the current directory.
|
||||
|
||||
If you specify a package name but do not specify a version or if you remove all of a package's versions then the registry will remove the root package entry entirely.
|
||||
|
||||
Even if you unpublish a package version, that specific name and version combination can never be reused.
|
||||
In order to publish the package again, you must use a new version number.
|
||||
If you unpublish the entire package, you may not publish any new versions of that package until 24 hours have passed.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `force`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Removes various protections against unfortunate side effects, common
|
||||
mistakes, unnecessary performance degradation, and malicious input.
|
||||
|
||||
* Allow clobbering non-npm files in global installs.
|
||||
* Allow the `npm version` command to work on an unclean git repository.
|
||||
* Allow deleting the cache folder with `npm cache clean`.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of npm.
|
||||
* Allow installing packages that have an `engines` declaration requiring a
|
||||
different version of `node`, even if `--engine-strict` is enabled.
|
||||
* Allow `npm audit fix` to install modules outside your stated dependency
|
||||
range (including SemVer-major changes).
|
||||
* Allow unpublishing all versions of a published package.
|
||||
* Allow conflicting peerDependencies to be installed in the root project.
|
||||
* Implicitly set `--yes` during `npm init`.
|
||||
* Allow clobbering existing values in `npm pkg`
|
||||
* Allow unpublishing of entire packages (not just a single version).
|
||||
|
||||
If you don't have a clear idea of what you want to do, it is strongly
|
||||
recommended that you do not use this option!
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm deprecate](/commands/npm-deprecate)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
* [npm owner](/commands/npm-owner)
|
||||
* [npm login](/commands/npm-adduser)
|
||||
Generated
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: npm-unstar
|
||||
section: 1
|
||||
description: Remove an item from your favorite packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm unstar [<package-spec>...]
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
"Unstarring" a package is the opposite of [`npm star`](/commands/npm-star), it removes an item from your list of favorite packages.
|
||||
|
||||
### More
|
||||
|
||||
There's also these extra commands to help you manage your favorite packages:
|
||||
|
||||
#### Star
|
||||
|
||||
You can "star" a package using [`npm star`](/commands/npm-star)
|
||||
|
||||
#### Listing stars
|
||||
|
||||
You can see all your starred packages using [`npm stars`](/commands/npm-stars)
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
#### `unicode`
|
||||
|
||||
* Default: false on windows, true on mac/unix systems with a unicode locale,
|
||||
as defined by the `LC_ALL`, `LC_CTYPE`, or `LANG` environment variables.
|
||||
* Type: Boolean
|
||||
|
||||
When set to true, npm uses unicode characters in the tree output. When
|
||||
false, it uses ascii characters instead of unicode glyphs.
|
||||
|
||||
|
||||
|
||||
#### `otp`
|
||||
|
||||
* Default: null
|
||||
* Type: null or String
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It's needed
|
||||
when publishing or changing package permissions with `npm access`.
|
||||
|
||||
If not set, and a registry response fails with a challenge for a one-time
|
||||
password, npm will prompt on the command line for one.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm star](/commands/npm-star)
|
||||
* [npm stars](/commands/npm-stars)
|
||||
* [npm view](/commands/npm-view)
|
||||
* [npm whoami](/commands/npm-whoami)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
|
||||
Generated
Vendored
+521
@@ -0,0 +1,521 @@
|
||||
---
|
||||
title: npm-update
|
||||
section: 1
|
||||
description: Update packages
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm update [<pkg>...]
|
||||
|
||||
aliases: u, up, upgrade, udpate
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command will update all the packages listed to the latest version (specified by the [`tag` config](/using-npm/config#tag)), respecting the semver constraints of both your package and its dependencies (if they also require the same package).
|
||||
|
||||
It will also install missing packages.
|
||||
|
||||
If the `-g` flag is specified, this command will update globally installed packages.
|
||||
|
||||
If no package name is specified, all packages in the specified location (global or local) will be updated.
|
||||
|
||||
Note that by default `npm update` will not update the semver values of direct dependencies in your project `package.json`.
|
||||
If you want to also update values in `package.json` you can run: `npm update --save` (or add the `save=true` option to a [configuration file](/configuring-npm/npmrc) to make that the default behavior).
|
||||
|
||||
### Example
|
||||
|
||||
For the examples below, assume that the current package is `app` and it depends on dependencies, `dep1` (`dep2`, .. etc.).
|
||||
The published versions of `dep1` are:
|
||||
|
||||
```json
|
||||
{
|
||||
"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"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Caret Dependencies
|
||||
|
||||
If `app`'s `package.json` contains:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
"dep1": "^1.1.1"
|
||||
}
|
||||
```
|
||||
|
||||
Then `npm update` will install `dep1@1.2.2`, because `1.2.2` is `latest` and
|
||||
`1.2.2` satisfies `^1.1.1`.
|
||||
|
||||
#### Tilde Dependencies
|
||||
|
||||
However, if `app`'s `package.json` contains:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
"dep1": "~1.1.1"
|
||||
}
|
||||
```
|
||||
|
||||
In this case, running `npm update` will install `dep1@1.1.2`.
|
||||
Even though the `latest` tag points to `1.2.2`, this version does not satisfy `~1.1.1`, which is equivalent to `>=1.1.1 <1.2.0`.
|
||||
So the highest-sorting version that satisfies
|
||||
`~1.1.1` is used, which is `1.1.2`.
|
||||
|
||||
#### Caret Dependencies below 1.0.0
|
||||
|
||||
Suppose `app` has a caret dependency on a version below `1.0.0`, for example:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
"dep1": "^0.2.0"
|
||||
}
|
||||
```
|
||||
|
||||
`npm update` will install `dep1@0.2.0`.
|
||||
|
||||
If the dependence were on `^0.4.0`:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
"dep1": "^0.4.0"
|
||||
}
|
||||
```
|
||||
|
||||
Then `npm update` will install `dep1@0.4.1`, because that is the highest-sorting version that satisfies `^0.4.0` (`>= 0.4.0 <0.5.0`)
|
||||
|
||||
|
||||
#### Subdependencies
|
||||
|
||||
Suppose your app now also has a dependency on `dep2`
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-app",
|
||||
"dependencies": {
|
||||
"dep1": "^1.0.0",
|
||||
"dep2": "1.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
and `dep2` itself depends on this limited range of `dep1`
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "dep2",
|
||||
"dependencies": {
|
||||
"dep1": "~1.1.1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then `npm update` will install `dep1@1.1.2` because that is the highest version that `dep2` allows.
|
||||
npm will prioritize having a single version of `dep1` in your tree rather than two when that single version can satisfy the semver requirements of multiple dependencies in your tree.
|
||||
In this case if you really did need your package to use a newer version you would need to use `npm install`.
|
||||
|
||||
|
||||
#### Updating Globally-Installed Packages
|
||||
|
||||
`npm update -g` will apply the `update` action to each globally installed package that is `outdated` -- that is, has a version that is different from `wanted`.
|
||||
|
||||
Note: Globally installed packages are treated as if they are installed with a caret semver range specified.
|
||||
So if you require to update to `latest` you may need to run `npm install -g [<pkg>...]`
|
||||
|
||||
NOTE: If a package has been upgraded to a version newer than `latest`, it will be _downgraded_.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `save`
|
||||
|
||||
* Default: `true` unless when using `npm update` where it defaults to `false`
|
||||
* Type: Boolean
|
||||
|
||||
Save installed packages to a `package.json` file as dependencies.
|
||||
|
||||
When used with the `npm rm` command, removes the dependency from
|
||||
`package.json`.
|
||||
|
||||
Will also prevent writing to `package-lock.json` if set to `false`.
|
||||
|
||||
|
||||
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
|
||||
|
||||
#### `install-strategy`
|
||||
|
||||
* Default: "hoisted"
|
||||
* Type: "hoisted", "nested", "shallow", or "linked"
|
||||
|
||||
Sets the strategy for installing packages in node_modules. hoisted
|
||||
(default): Install non-duplicated in top-level, and duplicated as necessary
|
||||
within directory structure. nested: (formerly --legacy-bundling) install in
|
||||
place, no hoisting. shallow (formerly --global-style) only install direct
|
||||
deps at top-level. linked: (experimental) install in node_modules/.store,
|
||||
link in place, unhoisted.
|
||||
|
||||
|
||||
|
||||
#### `legacy-bundling`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=nested`
|
||||
|
||||
Instead of hoisting package installs in `node_modules`, install packages in
|
||||
the same manner that they are depended on. This may cause very deep
|
||||
directory structures and duplicate package installs as there is no
|
||||
de-duplicating. Sets `--install-strategy=nested`.
|
||||
|
||||
|
||||
|
||||
#### `global-style`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
* DEPRECATED: This option has been deprecated in favor of
|
||||
`--install-strategy=shallow`
|
||||
|
||||
Only install direct dependencies in the top level `node_modules`, but hoist
|
||||
on deeper dependencies. Sets `--install-strategy=shallow`.
|
||||
|
||||
|
||||
|
||||
#### `omit`
|
||||
|
||||
* Default: 'dev' if the `NODE_ENV` environment variable is set to
|
||||
'production'; otherwise, empty.
|
||||
* Type: "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Dependency types to omit from the installation tree on disk.
|
||||
|
||||
Note that these dependencies _are_ still resolved and added to the
|
||||
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
|
||||
physically installed on disk.
|
||||
|
||||
If a package type appears in both the `--include` and `--omit` lists, then
|
||||
it will be included.
|
||||
|
||||
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
|
||||
variable will be set to `'production'` for all lifecycle scripts.
|
||||
|
||||
|
||||
|
||||
#### `include`
|
||||
|
||||
* Default:
|
||||
* Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
|
||||
|
||||
Option that allows for defining which types of dependencies to install.
|
||||
|
||||
This is the inverse of `--omit=<type>`.
|
||||
|
||||
Dependency types specified in `--include` will not be omitted, regardless of
|
||||
the order in which omit/include are specified on the command-line.
|
||||
|
||||
|
||||
|
||||
#### `strict-peer-deps`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
|
||||
conflicting `peerDependencies` will be treated as an install failure, even
|
||||
if npm could reasonably guess the appropriate resolution based on non-peer
|
||||
dependency relationships.
|
||||
|
||||
By default, conflicting `peerDependencies` deep in the dependency graph will
|
||||
be resolved using the nearest non-peer dependency specification, even if
|
||||
doing so will result in some packages receiving a peer dependency outside
|
||||
the range set in their package's `peerDependencies` object.
|
||||
|
||||
When such an override is performed, a warning is printed, explaining the
|
||||
conflict and the packages involved. If `--strict-peer-deps` is set, then
|
||||
this warning is treated as a failure.
|
||||
|
||||
|
||||
|
||||
#### `package-lock`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to false, then ignore `package-lock.json` files when installing. This
|
||||
will also prevent _writing_ `package-lock.json` if `save` is true.
|
||||
|
||||
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
* Default: `false` unless when using `npm pack` or `npm publish` where it
|
||||
defaults to `true`
|
||||
* Type: Boolean
|
||||
|
||||
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
|
||||
scripts for installed packages in the foreground process, sharing standard
|
||||
input, output, and error with the main npm process.
|
||||
|
||||
Note that this will generally make installs run slower, and be much noisier,
|
||||
but can be useful for debugging.
|
||||
|
||||
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
#### `allow-scripts`
|
||||
|
||||
* Default: ""
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Comma-separated list of packages whose install-time lifecycle scripts
|
||||
(`preinstall`, `install`, `postinstall`, and `prepare` for non-registry
|
||||
dependencies) are allowed to run.
|
||||
|
||||
This setting is intended for one-off and global contexts: `npm exec`, `npx`,
|
||||
and `npm install -g`, where no project `package.json` is involved. For
|
||||
team-wide policy in a project, use the `allowScripts` field in
|
||||
`package.json` (which also supports explicit denials), or configure it in
|
||||
`.npmrc`. Passing `--allow-scripts` on the command line during a
|
||||
project-scoped `npm install`, `ci`, `update`, or `rebuild` is an error.
|
||||
|
||||
Each name is matched against a dependency's resolved identity, not against
|
||||
the package's self-reported name. `--ignore-scripts` and
|
||||
`--dangerously-allow-all-scripts` both override this setting.
|
||||
|
||||
|
||||
|
||||
#### `strict-allow-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, turn the install-script policy from a warning into a hard error:
|
||||
any dependency with install scripts not covered by `allowScripts` will fail
|
||||
the install instead of running with a notice.
|
||||
|
||||
Dependencies explicitly denied with `false` in `allowScripts` are always
|
||||
silently skipped; this setting only affects unreviewed entries.
|
||||
`--ignore-scripts` and `--dangerously-allow-all-scripts` both override this
|
||||
setting.
|
||||
|
||||
|
||||
|
||||
#### `dangerously-allow-all-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If `true`, bypass the `allowScripts` policy entirely and run every
|
||||
dependency install script regardless of whether it was approved or denied.
|
||||
Intended as a migration escape hatch only; its use is strongly discouraged.
|
||||
`--ignore-scripts` still takes precedence over this setting.
|
||||
|
||||
|
||||
|
||||
#### `audit`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" submit audit reports alongside the current npm command to the
|
||||
default registry and all registries configured for scopes. See the
|
||||
documentation for [`npm audit`](/commands/npm-audit) for details on what is
|
||||
submitted.
|
||||
|
||||
|
||||
|
||||
#### `before`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Date
|
||||
|
||||
If passed to `npm install`, will rebuild the npm tree such that only
|
||||
versions that were available **on or before** the given date are installed.
|
||||
If there are no versions available for the current set of dependencies, the
|
||||
command will error.
|
||||
|
||||
If the requested version is a `dist-tag` and the given tag does not pass the
|
||||
`--before` filter, the most recent version less than or equal to that tag
|
||||
will be used. For example, `foo@latest` might install `foo@1.2` even though
|
||||
`latest` is `2.0`.
|
||||
|
||||
If `before` and `min-release-age` are both set in the same source, `before`
|
||||
wins (an explicit absolute date overrides a relative window). Across
|
||||
sources, the standard precedence applies (cli > env > project > user >
|
||||
global), so a higher-priority source can always relax or override a
|
||||
lower-priority one.
|
||||
|
||||
|
||||
|
||||
#### `min-release-age`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Number
|
||||
|
||||
If set, npm will build the npm tree such that only versions that were
|
||||
available more than the given number of days ago will be installed. If there
|
||||
are no versions available for the current set of dependencies, the command
|
||||
will error.
|
||||
|
||||
This flag is a complement to `before`, which accepts an exact date instead
|
||||
of a relative number of days. The two may coexist (e.g. `min-release-age` in
|
||||
your `.npmrc` is preserved when npm internally spawns a sub-process with
|
||||
`--before` while preparing a `git:` or `github:` dependency); when both
|
||||
apply, `before` wins within a single source and across sources the standard
|
||||
precedence rules apply.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `bin-links`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tells npm to create symlinks (or `.cmd` shims on Windows) for package
|
||||
executables.
|
||||
|
||||
Set to false to have it not do this. This can be used to work around the
|
||||
fact that some file systems don't support symlinks, even on ostensibly Unix
|
||||
systems.
|
||||
|
||||
|
||||
|
||||
#### `fund`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
When "true" displays the message at the end of each `npm install`
|
||||
acknowledging the number of dependencies looking for funding. See [`npm
|
||||
fund`](/commands/npm-fund) for details.
|
||||
|
||||
|
||||
|
||||
#### `dry-run`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Indicates that you don't want npm to make any changes and that it should
|
||||
only report what it would have done. This can be passed into any of the
|
||||
commands that modify your local installation, eg, `install`, `update`,
|
||||
`dedupe`, `uninstall`, as well as `pack` and `publish`.
|
||||
|
||||
Note: This is NOT honored by other network related commands, eg `dist-tags`,
|
||||
`owner`, etc.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `install-links`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
When set file: protocol dependencies will be packed and installed as regular
|
||||
dependencies instead of creating a symlink. This option has no effect on
|
||||
workspaces.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm outdated](/commands/npm-outdated)
|
||||
* [npm shrinkwrap](/commands/npm-shrinkwrap)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm ls](/commands/npm-ls)
|
||||
Generated
Vendored
+256
@@ -0,0 +1,256 @@
|
||||
---
|
||||
title: npm-version
|
||||
section: 1
|
||||
description: Bump a package version
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]
|
||||
|
||||
alias: verison
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `allow-same-version`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Prevents throwing an error when `npm version` is used to set the new version
|
||||
to the same value as the current version.
|
||||
|
||||
|
||||
|
||||
#### `commit-hooks`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Run git commit hooks when using the `npm version` command.
|
||||
|
||||
|
||||
|
||||
#### `git-tag-version`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
Tag the commit when using the `npm version` command. Setting this to false
|
||||
results in no commit being made at all.
|
||||
|
||||
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `preid`
|
||||
|
||||
* Default: ""
|
||||
* Type: String
|
||||
|
||||
The "prerelease identifier" to use as a prefix for the "prerelease" part of
|
||||
a semver. Like the `rc` in `1.2.0-rc.8`.
|
||||
|
||||
|
||||
|
||||
#### `sign-git-tag`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, then the `npm version` command will tag the version using
|
||||
`-s` to add a signature.
|
||||
|
||||
Note that git requires you to have set up GPG keys in your git configs for
|
||||
this to work properly.
|
||||
|
||||
|
||||
|
||||
#### `save`
|
||||
|
||||
* Default: `true` unless when using `npm update` where it defaults to `false`
|
||||
* Type: Boolean
|
||||
|
||||
Save installed packages to a `package.json` file as dependencies.
|
||||
|
||||
When used with the `npm rm` command, removes the dependency from
|
||||
`package.json`.
|
||||
|
||||
Will also prevent writing to `package-lock.json` if set to `false`.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces-update`
|
||||
|
||||
* Default: true
|
||||
* Type: Boolean
|
||||
|
||||
If set to true, the npm cli will run an update after operations that may
|
||||
possibly change the workspaces installed to the `node_modules` folder.
|
||||
|
||||
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `ignore-scripts`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
If true, npm does not run scripts specified in package.json files.
|
||||
|
||||
Note that commands explicitly intended to run a particular script, such as
|
||||
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run` will still
|
||||
run their intended script if `ignore-scripts` is set, but they will *not*
|
||||
run any pre- or post-scripts.
|
||||
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
Run this in a package directory to bump the version and write the new data back to `package.json`, `package-lock.json`, and, if present,
|
||||
`npm-shrinkwrap.json`.
|
||||
|
||||
The `newversion` argument should be a valid semver string, a valid second argument to [semver.inc](https://github.com/npm/node-semver#functions) (one of `patch`, `minor`, `major`, `prepatch`, `preminor`, `premajor`, `prerelease`), or `from-git`.
|
||||
In the second case, the existing version will be incremented by 1 in the specified field.
|
||||
`from-git` will try to read the latest git tag, and use that as the new npm version.
|
||||
|
||||
**Note:** If the current version is a prerelease version, `patch` will simply remove the prerelease suffix without incrementing the patch version number. For example, `1.2.0-5` becomes `1.2.0` with `npm version patch`, not `1.2.1`.
|
||||
|
||||
If run in a git repo, it will also create a version commit and tag.
|
||||
This behavior is controlled by `git-tag-version` (see below), and can be disabled on the command line by running `npm --no-git-tag-version version`.
|
||||
It will fail if the working directory is not clean, unless the `-f` or `--force` flag is set.
|
||||
|
||||
**Note:** Git integration requires a reasonably recent version of git (2.0.0 or later is recommended). If you encounter issues with git commands, ensure your git installation is up to date.
|
||||
|
||||
If supplied with `-m` or [`--message` config](/using-npm/config#message) option, npm will use it as a commit message when creating a version commit.
|
||||
If the `message` config contains `%s` then that will be replaced with the resulting version number.
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npm version patch -m "Upgrade to %s for reasons"
|
||||
```
|
||||
|
||||
If the [`sign-git-tag` config](/using-npm/config#sign-git-tag) is set, then the tag will be signed using the `-s` 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:
|
||||
|
||||
```bash
|
||||
$ 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:
|
||||
```
|
||||
|
||||
If `preversion`, `version`, or `postversion` are in the `scripts` property of the package.json, they will be executed as part of running `npm version`.
|
||||
|
||||
The exact order of execution is as follows:
|
||||
|
||||
1. 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 `--force` flag is set.
|
||||
2. Run the `preversion` script.
|
||||
These scripts have access to the old `version` 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 `git add`.
|
||||
3. Bump `version` in `package.json` as requested (`patch`, `minor`, `major`, etc).
|
||||
4. Run the `version` script.
|
||||
These scripts have access to the new `version` 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 `git add`.
|
||||
5. Commit and tag.
|
||||
6. Run the `postversion` script.
|
||||
Use it to clean up the file system or automatically push the commit and/or tag.
|
||||
|
||||
For the `preversion`, `version` and `postversion` scripts, npm also sets the [environment variables](/using-npm/scripts#environment) `npm_old_version` and `npm_new_version`.
|
||||
|
||||
Take the following example:
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"preversion": "npm test",
|
||||
"version": "npm run build && git add -A dist",
|
||||
"postversion": "git push && git push --tags && rm -rf build/temp"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This runs all your tests and proceeds only if they pass.
|
||||
Then runs your `build` script, and adds everything in the `dist` directory to the commit.
|
||||
After the commit, it pushes the new commit and tag up to the server, and deletes the `build/temp` directory.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm init](/commands/npm-init)
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [config](/using-npm/config)
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
---
|
||||
title: npm-view
|
||||
section: 1
|
||||
description: View registry info
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm view [<package-spec>] [<field>[.subfield]...]
|
||||
|
||||
aliases: info, show, v
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command shows data about a package and prints it to stdout.
|
||||
|
||||
As an example, to view information about the `connect` package from the registry, you would run:
|
||||
|
||||
```bash
|
||||
npm view connect
|
||||
```
|
||||
|
||||
The default version is `"latest"` if unspecified.
|
||||
|
||||
Field names can be specified after the package descriptor.
|
||||
For example, to show the dependencies of the `ronn` package at version
|
||||
`0.3.5`, you could do the following:
|
||||
|
||||
```bash
|
||||
npm view ronn@0.3.5 dependencies
|
||||
```
|
||||
|
||||
By default, `npm view` shows data about the current project context (by looking for a `package.json`).
|
||||
To show field data for the current project use a file path (i.e.
|
||||
`.`):
|
||||
|
||||
```bash
|
||||
npm view . dependencies
|
||||
```
|
||||
|
||||
You can view child fields by separating them with a period.
|
||||
To view the git repository URL for the latest version of `npm`, you would run the following command:
|
||||
|
||||
```bash
|
||||
npm view npm repository.url
|
||||
```
|
||||
|
||||
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 could write the following:
|
||||
|
||||
```bash
|
||||
npm view opts@$(npm view ronn dependencies.opts)
|
||||
```
|
||||
|
||||
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 email addresses for the `express` package, you would run:
|
||||
|
||||
```bash
|
||||
npm view express contributors.email
|
||||
```
|
||||
|
||||
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 run:
|
||||
|
||||
```bash
|
||||
npm view express contributors[0].email
|
||||
```
|
||||
|
||||
If the field value you are querying for is a property of an object, you should run:
|
||||
|
||||
```bash
|
||||
npm view express time'[4.8.0]'
|
||||
```
|
||||
|
||||
Note: When accessing object properties that contain special characters or numeric keys, you need to use quotes around the key name.
|
||||
For example, to get the publish time of a specific version:
|
||||
|
||||
```bash
|
||||
npm view express "time[4.17.1]"
|
||||
```
|
||||
|
||||
Without quotes, the shell may interpret the square brackets as glob patterns, causing the command to fail.
|
||||
You can also access the time field for a specific version by specifying the version in the package descriptor:
|
||||
|
||||
```bash
|
||||
npm view express@4.17.1 time
|
||||
```
|
||||
|
||||
This will return all version-time pairs, but the context will be for that specific version.
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
npm view express contributors.name contributors.email
|
||||
```
|
||||
|
||||
"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 [`package.json`](/configuring-npm/package-json) for more on this.)
|
||||
|
||||
```bash
|
||||
npm view npm contributors
|
||||
```
|
||||
|
||||
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`:
|
||||
|
||||
```bash
|
||||
npm view yui3@'>0.5.4' dependencies.jsdom
|
||||
```
|
||||
|
||||
To show the `connect` package version history, you can do this:
|
||||
|
||||
```bash
|
||||
npm view connect versions
|
||||
```
|
||||
|
||||
### Field Access Patterns
|
||||
|
||||
The `npm view` command supports different ways to access nested fields and array elements in package metadata. Understanding these patterns makes it easier to extract specific information.
|
||||
|
||||
#### Nested Object Fields
|
||||
|
||||
Use dot notation to access nested object fields:
|
||||
|
||||
```bash
|
||||
# Access nested properties
|
||||
npm view npm repository.url
|
||||
npm view express bugs.url
|
||||
```
|
||||
|
||||
#### Array Element Access
|
||||
|
||||
For arrays, use numeric indices in square brackets to access specific elements:
|
||||
|
||||
```bash
|
||||
# Get the first contributor's email
|
||||
npm view express contributors[0].email
|
||||
|
||||
# Get the second maintainer's name
|
||||
npm view express maintainers[1].name
|
||||
```
|
||||
|
||||
#### Object Property Access
|
||||
|
||||
For object properties (like accessing specific versions in the `time` field), use bracket notation with the property name in quotes:
|
||||
|
||||
```bash
|
||||
# Get publish time for a specific version
|
||||
npm view express "time[4.17.1]"
|
||||
|
||||
# Get dist-tags
|
||||
npm view express "dist-tags.latest"
|
||||
```
|
||||
|
||||
#### Extracting Fields from Arrays
|
||||
|
||||
Request a non-numeric field on an array to get all values from objects in the list:
|
||||
|
||||
```bash
|
||||
# Get all contributor emails
|
||||
npm view express contributors.email
|
||||
|
||||
# Get all contributor names
|
||||
npm view express contributors.name
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `json`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Whether or not to output JSON data, rather than the normal output.
|
||||
|
||||
* In `npm pkg set` it enables parsing set values with JSON.parse() before
|
||||
saving them to your `package.json`.
|
||||
|
||||
Not supported by all npm commands.
|
||||
|
||||
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
### Output
|
||||
|
||||
If only a single string field for a single version is output, then it will not be colorized or quoted, to enable piping the output to another command.
|
||||
If the field is an object, it will be output as a JavaScript object literal.
|
||||
|
||||
If the `--json` flag is given, the outputted fields will be JSON.
|
||||
|
||||
If the version range matches multiple versions then each printed value will be prefixed with the version it applies to.
|
||||
|
||||
If multiple fields are requested, then each of them is prefixed with the field name.
|
||||
|
||||
### See Also
|
||||
|
||||
* [package spec](/using-npm/package-spec)
|
||||
* [npm search](/commands/npm-search)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm docs](/commands/npm-docs)
|
||||
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: npm-whoami
|
||||
section: 1
|
||||
description: Display npm username
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm whoami
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Description
|
||||
|
||||
Display the npm username of the currently logged-in user.
|
||||
|
||||
If logged into a registry that provides token-based authentication, then connect to the `/-/whoami` registry endpoint to find the username associated with the token, and print to standard output.
|
||||
|
||||
If logged into a registry that uses Basic Auth, then simply print the `username` portion of the authentication string.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `registry`
|
||||
|
||||
* Default: "https://registry.npmjs.org/"
|
||||
* Type: URL
|
||||
|
||||
The base URL of the npm registry.
|
||||
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
---
|
||||
title: npm
|
||||
section: 1
|
||||
description: javascript package manager
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm
|
||||
```
|
||||
|
||||
Note: This command is unaware of workspaces.
|
||||
|
||||
### Version
|
||||
|
||||
11.16.0
|
||||
|
||||
### Description
|
||||
|
||||
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.
|
||||
|
||||
It is extremely configurable to support a variety of use cases.
|
||||
Most commonly, you use it to publish, discover, install, and develop node programs.
|
||||
|
||||
Run `npm help` to get a list of available commands.
|
||||
|
||||
### Important
|
||||
|
||||
npm comes preconfigured to use npm'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://docs.npmjs.com/policies/terms.
|
||||
|
||||
You can configure npm to use any compatible registry you like, and even run your own registry.
|
||||
Use of someone else's registry is governed by their terms of use.
|
||||
|
||||
### Introduction
|
||||
|
||||
You probably got npm because you want to install stuff.
|
||||
|
||||
The very first thing you will most likely want to run in any node program is `npm install` to install its dependencies.
|
||||
|
||||
You can also run `npm install blerg` to install the latest version of "blerg". Check out [`npm install`](/commands/npm-install) for more info.
|
||||
It can do a lot of stuff.
|
||||
|
||||
Use the `npm search` command to show everything that's available in the public registry.
|
||||
Use `npm ls` to show everything you've installed.
|
||||
|
||||
### Dependencies
|
||||
|
||||
If a package lists a dependency using a git URL, npm will install that dependency using the [`git`](https://github.com/git-guides/install-git) command and will generate an error if it is not installed.
|
||||
|
||||
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](https://github.com/nodejs/node-gyp) for that task.
|
||||
For a Unix system, [node-gyp](https://github.com/nodejs/node-gyp) 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](https://github.com/nodejs/node-gyp) and the [node-gyp Wiki](https://github.com/nodejs/node-gyp/wiki).
|
||||
|
||||
### Directories
|
||||
|
||||
See [`folders`](/configuring-npm/folders) to learn about where npm puts stuff.
|
||||
|
||||
In particular, npm has two modes of operation:
|
||||
|
||||
* local mode:
|
||||
npm installs packages into the current project directory, which defaults to the current working directory.
|
||||
Packages install to `./node_modules`, and bins to `./node_modules/.bin`.
|
||||
* global mode:
|
||||
npm installs packages into the install prefix at `$NPM_CONFIG_PREFIX/lib/node_modules` and bins to `$NPM_CONFIG_PREFIX/bin`.
|
||||
|
||||
Local mode is the default.
|
||||
Use `-g` or `--global` on any command to run in global mode instead.
|
||||
|
||||
### Developer Usage
|
||||
|
||||
If you're using npm to develop and publish your code, check out the following help topics:
|
||||
|
||||
* json:
|
||||
Make a package.json file.
|
||||
See [`package.json`](/configuring-npm/package-json).
|
||||
* link:
|
||||
Links your current working code into Node's path, so that you don't have to reinstall every time you make a change.
|
||||
Use [`npm link`](/commands/npm-link) to do this.
|
||||
* 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 [`npm install`](/commands/npm-install)
|
||||
* adduser:
|
||||
Create an account or log in.
|
||||
When you do this, npm will store credentials in the user config file.
|
||||
* publish:
|
||||
Use the [`npm publish`](/commands/npm-publish) command to upload your code to the registry.
|
||||
|
||||
#### Configuration
|
||||
|
||||
npm is extremely configurable.
|
||||
It reads its configuration options from 5 places.
|
||||
|
||||
* Command line switches:
|
||||
Set a config with `--key val`.
|
||||
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 you do not provide a value (`--key`) then the option is set to boolean `true`.
|
||||
* Environment Variables:
|
||||
Set any config by prefixing the name in an environment variable with `NPM_CONFIG_`.
|
||||
For example, `export NPM_CONFIG_KEY=val`.
|
||||
* User Configs:
|
||||
The file at `$HOME/.npmrc` is an ini-formatted list of configs.
|
||||
If present, it is parsed.
|
||||
If the `userconfig` option is set in the cli or env, that file will be used instead.
|
||||
* Global Configs:
|
||||
The file found at `./etc/npmrc` (relative to the global prefix will be parsed if it is found.
|
||||
See [`npm prefix`](/commands/npm-prefix) for more info on the global prefix.
|
||||
If the `globalconfig` option is set in the cli, env, or user config, then that file is parsed instead.
|
||||
* Defaults:
|
||||
npm's default configuration options are defined in `lib/utils/config/definitions.js`.
|
||||
These must not be changed.
|
||||
|
||||
See [`config`](/using-npm/config) for much, much, more information.
|
||||
|
||||
### Contributions
|
||||
|
||||
Patches welcome!
|
||||
|
||||
If you would like to help, but don't know what to work on, read the [contributing guidelines](https://github.com/npm/cli/blob/latest/CONTRIBUTING.md) and check the issues list.
|
||||
|
||||
### Bugs
|
||||
|
||||
When you find issues, please report them:
|
||||
<https://github.com/npm/cli/issues>
|
||||
|
||||
Please be sure to follow the template and bug reporting guidelines.
|
||||
|
||||
### Feature Requests
|
||||
|
||||
Discuss new feature ideas on our discussion forum:
|
||||
|
||||
* <https://github.com/orgs/community/discussions/categories/npm>
|
||||
|
||||
Or suggest formal RFC proposals:
|
||||
|
||||
* <https://github.com/npm/rfcs>
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm help](/commands/npm-help)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm prefix](/commands/npm-prefix)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
---
|
||||
title: npx
|
||||
section: 1
|
||||
description: Run a command from a local or remote npm package
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npx -- <pkg>[@<version>] [args...]
|
||||
npx --package=<pkg>[@<version>] -- <cmd> [args...]
|
||||
npx -c '<cmd> [args...]'
|
||||
npx --package=foo -c '<cmd> [args...]'
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command allows you to run an arbitrary command from an npm package (either one installed locally, or fetched remotely), in a similar context as running it via `npm run`.
|
||||
|
||||
Run this command to execute a package's binary. Any options and arguments after the package name are passed directly to the executed command, not to npx itself. For example, `npx create-react-app my-app --template typescript` will pass `my-app` and `--template typescript` to the `create-react-app` command. To see what options a specific package accepts, consult that package's documentation (e.g., at npmjs.com or in its repository).
|
||||
|
||||
Whatever packages are specified by the `--package` option will be provided in the `PATH` of the executed command, along with any locally installed package executables.
|
||||
The `--package` option may be specified multiple times, to execute the supplied command in an environment where all specified packages are available.
|
||||
|
||||
If any requested packages are not present in the local project dependencies, then they are installed to a folder in the npm cache, which is added to the `PATH` environment variable in the executed process.
|
||||
A prompt is printed (which can be suppressed by providing either `--yes` or `--no`).
|
||||
|
||||
Package names provided without a specifier will be matched with whatever version exists in the local project.
|
||||
Package names with a specifier will only be considered a match if they have the exact same name and version as the local dependency.
|
||||
|
||||
If no `-c` or `--call` option is provided, then the positional arguments are used to generate the command string.
|
||||
If no `--package` options are provided, then npm will attempt to determine the executable name from the package specifier provided as the first positional argument according to the following heuristic:
|
||||
|
||||
- If the package has a single entry in its `bin` field in `package.json`, or if all entries are aliases of the same command, then that command will be used.
|
||||
- If the package has multiple `bin` entries, and one of them matches the unscoped portion of the `name` field, then that command will be used.
|
||||
- If this does not result in exactly one option (either because there are no bin entries, or none of them match the `name` of the package), then
|
||||
`npm exec` exits with an error.
|
||||
|
||||
To run a binary _other than_ the named binary, specify one or more
|
||||
`--package` options, which will prevent npm from inferring the package from the first command argument.
|
||||
|
||||
### `npx` vs `npm exec`
|
||||
|
||||
When run via the `npx` binary, all flags and options *must* be set prior to any positional arguments.
|
||||
When run via `npm exec`, a double-hyphen `--` flag can be used to suppress npm's parsing of switches and options that should be sent to the executed command.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
$ npx foo@latest bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
In this case, npm will resolve the `foo` package name, and run the following command:
|
||||
|
||||
```
|
||||
$ foo bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
Since the `--package` option comes _after_ the positional arguments, it is treated as an argument to the executed command.
|
||||
|
||||
In contrast, due to npm's argument parsing logic, running this command is different:
|
||||
|
||||
```
|
||||
$ npm exec foo@latest bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
In this case, npm will parse the `--package` option first, resolving the
|
||||
`@npmcli/foo` package.
|
||||
Then, it will execute the following command in that context:
|
||||
|
||||
```
|
||||
$ foo@latest bar
|
||||
```
|
||||
|
||||
The double-hyphen character is recommended to explicitly tell npm to stop parsing command line options and switches.
|
||||
The following command would thus be equivalent to the `npx` command above:
|
||||
|
||||
```
|
||||
$ npm exec -- foo@latest bar --package=@npmcli/foo
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
Run the version of `tap` in the local dependencies, with the provided arguments:
|
||||
|
||||
```
|
||||
$ npm exec -- tap --bail test/foo.js
|
||||
$ npx tap --bail test/foo.js
|
||||
```
|
||||
|
||||
Run a command _other than_ the command whose name matches the package name by specifying a `--package` option:
|
||||
|
||||
```
|
||||
$ npm exec --package=foo -- bar --bar-argument
|
||||
# ~ or ~
|
||||
$ npx --package=foo bar --bar-argument
|
||||
```
|
||||
|
||||
Run an arbitrary shell script, in the context of the current project:
|
||||
|
||||
```
|
||||
$ npm x -c 'eslint && say "hooray, lint passed"'
|
||||
$ npx -c 'eslint && say "hooray, lint passed"'
|
||||
```
|
||||
|
||||
### Compatibility with Older npx Versions
|
||||
|
||||
The `npx` binary was rewritten in npm v7.0.0, and the standalone `npx` package deprecated at that time.
|
||||
`npx` uses the `npm exec` command instead of a separate argument parser and install process, with some affordances to maintain backwards compatibility with the arguments it accepted in previous versions.
|
||||
|
||||
This resulted in some shifts in its functionality:
|
||||
|
||||
- Any `npm` config value may be provided.
|
||||
- To prevent security and user-experience problems from mistyping package names, `npx` prompts before installing anything.
|
||||
Suppress this prompt with the `-y` or `--yes` option.
|
||||
- The `--no-install` option is deprecated, and will be converted to `--no`.
|
||||
- Shell fallback functionality is removed, as it is not advisable.
|
||||
- The `-p` argument is a shorthand for `--parseable` in npm, but shorthand for `--package` in npx.
|
||||
This is maintained, but only for the `npx` executable.
|
||||
- The `--ignore-existing` option is removed.
|
||||
Locally installed bins are always present in the executed process `PATH`.
|
||||
- The `--npm` option is removed.
|
||||
`npx` will always use the `npm` it ships with.
|
||||
- The `--node-arg` and `-n` options have been removed.
|
||||
Use [`NODE_OPTIONS`](https://nodejs.org/api/cli.html#node_optionsoptions) instead: e.g.,
|
||||
`NODE_OPTIONS="--trace-warnings --trace-exit" npx foo --random=true`
|
||||
- The `--always-spawn` option is redundant, and thus removed.
|
||||
- The `--shell` option is replaced with `--script-shell`, but maintained in the `npx` executable for backwards compatibility.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm run](/commands/npm-run)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm test](/commands/npm-test)
|
||||
* [npm start](/commands/npm-start)
|
||||
* [npm restart](/commands/npm-restart)
|
||||
* [npm stop](/commands/npm-stop)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npm exec](/commands/npm-exec)
|
||||
Generated
Vendored
+172
@@ -0,0 +1,172 @@
|
||||
---
|
||||
title: Folders
|
||||
section: 5
|
||||
description: Folder structures used by npm
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
npm puts various things on your computer.
|
||||
That's its job.
|
||||
|
||||
This document will tell you what it puts where.
|
||||
|
||||
#### tl;dr
|
||||
|
||||
* Local install (default): puts stuff in `./node_modules` of the current package root.
|
||||
* Global install (with `-g`): puts stuff in /usr/local or wherever node is installed.
|
||||
* Install it **locally** if you're going to `require()` it.
|
||||
* Install it **globally** if you're going to run it on the command line.
|
||||
* If you need both, then install it in both places, or use `npm link`.
|
||||
|
||||
#### prefix Configuration
|
||||
|
||||
The [`prefix` config](/using-npm/config#prefix) defaults to the location where node is installed.
|
||||
On most systems, this is `/usr/local`.
|
||||
On Windows, it's `%AppData%\npm`.
|
||||
On Unix systems, it's one level up, since node is typically installed at `{prefix}/bin/node` rather than `{prefix}/node.exe`.
|
||||
|
||||
When the `global` 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.
|
||||
|
||||
#### Node Modules
|
||||
|
||||
Packages are dropped into the `node_modules` folder under the `prefix`.
|
||||
When installing locally, this means that you can `require("packagename")` to load its main module, or `require("packagename/lib/path/to/sub/module")` to load other modules.
|
||||
|
||||
Global installs on Unix systems go to `{prefix}/lib/node_modules`.
|
||||
Global installs on Windows go to `{prefix}/node_modules` (that is, no `lib` folder.)
|
||||
|
||||
Scoped packages are installed the same way, except they are grouped together in a sub-folder of the relevant `node_modules` folder with the name of that scope prefix by the @ symbol, e.g. `npm install @myorg/package` would place the package in `{prefix}/node_modules/@myorg/package`.
|
||||
See [`scope`](/using-npm/scope) for more details.
|
||||
|
||||
If you wish to `require()` a package, then install it locally.
|
||||
|
||||
#### Executables
|
||||
|
||||
When in global mode, executables are linked into `{prefix}/bin` on Unix, or directly into `{prefix}` on Windows.
|
||||
Ensure that path is in your terminal's `PATH` environment to run them.
|
||||
|
||||
When in local mode, executables are linked into `./node_modules/.bin` 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 `npm test`.)
|
||||
|
||||
#### Man Pages
|
||||
|
||||
When in global mode, man pages are linked into `{prefix}/share/man`.
|
||||
|
||||
When in local mode, man pages are not installed.
|
||||
|
||||
Man pages are not installed on Windows systems.
|
||||
|
||||
#### Cache
|
||||
|
||||
See [`npm cache`](/commands/npm-cache).
|
||||
Cache files are stored in `~/.npm` on Posix, or `%LocalAppData%/npm-cache` on Windows.
|
||||
|
||||
This is controlled by the [`cache` config](/using-npm/config#cache) param.
|
||||
|
||||
### More Information
|
||||
|
||||
When installing locally, npm first tries to find an appropriate `prefix` folder.
|
||||
This is so that `npm install foo@1.2.3` will install to the sensible root of your package, even if you happen to have `cd`ed into some other folder.
|
||||
|
||||
Starting at the $PWD, npm will walk up the folder tree checking for a folder that contains either a `package.json` file, or a `node_modules` 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.)
|
||||
|
||||
If no package root is found, then the current folder is used.
|
||||
|
||||
When you run `npm install foo@1.2.3`, then the package is loaded into the cache, and then unpacked into `./node_modules/foo`.
|
||||
Then, any of foo's dependencies are similarly unpacked into `./node_modules/foo/node_modules/...`.
|
||||
|
||||
Any bin files are symlinked to `./node_modules/.bin/`, so that they may be found by npm scripts when necessary.
|
||||
|
||||
#### Global Installation
|
||||
|
||||
If the [`global` config](/using-npm/config#global) is set to true, then npm will install packages "globally".
|
||||
|
||||
For global installation, packages are installed roughly the same way, but using the folders described above.
|
||||
|
||||
#### Cycles, Conflicts, and Folder Parsimony
|
||||
|
||||
Cycles are handled using the property of node's module system that it walks up the directories looking for `node_modules` folders.
|
||||
So, at every stage, if a package is already installed in an ancestor `node_modules` folder, then it is not installed at the current location.
|
||||
|
||||
Consider the case above, where `foo -> bar -> baz`.
|
||||
Imagine if, in addition to that, baz depended on bar, so you'd have:
|
||||
`foo -> bar -> baz -> bar -> baz ...`.
|
||||
However, since the folder structure is: `foo/node_modules/bar/node_modules/baz`, there's no need to put another copy of bar into `.../baz/node_modules`, since when baz calls `require("bar")`, it will get the copy that is installed in `foo/node_modules/bar`.
|
||||
|
||||
This shortcut is only used if the exact same version would be installed in multiple nested `node_modules` folders.
|
||||
It is still possible to have `a/node_modules/b/node_modules/a` if the two "a" packages are different versions.
|
||||
However, without repeating the exact same package multiple times, an infinite regress will always be prevented.
|
||||
|
||||
Another optimization can be made by installing dependencies at the highest level possible, below the localized "target" folder (hoisting).
|
||||
Since version 3, npm hoists dependencies by default.
|
||||
|
||||
#### Example
|
||||
|
||||
Consider this dependency graph:
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
In this case, we might expect a folder structure like this (with all dependencies hoisted to the highest level possible):
|
||||
|
||||
```bash
|
||||
foo
|
||||
+-- node_modules
|
||||
+-- blerg (1.2.5) <---[A]
|
||||
+-- bar (1.2.3) <---[B]
|
||||
| +-- node_modules
|
||||
| +-- baz (2.0.2) <---[C]
|
||||
+-- asdf (2.3.4)
|
||||
+-- baz (1.2.3) <---[D]
|
||||
+-- quux (3.2.0) <---[E]
|
||||
```
|
||||
|
||||
Since foo depends directly on `bar@1.2.3` and `baz@1.2.3`, those are installed in foo's `node_modules` folder.
|
||||
|
||||
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 `blerg@1.x`, it does not install another copy under [B].
|
||||
|
||||
Bar [B] also has dependencies on baz and asdf.
|
||||
Because it depends on `baz@2.x`, it cannot re-use the `baz@1.2.3` installed in the parent `node_modules` folder [D], and must install its own copy [C].
|
||||
In order to minimize duplication, npm hoists dependencies to the top level by default, so asdf is installed under [A].
|
||||
|
||||
Underneath bar, the `baz -> quux -> bar` 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.
|
||||
Likewise, quux's [E] folder tree is empty, because its dependency on bar is satisfied by the parent folder copy installed at [B].
|
||||
|
||||
For a graphical breakdown of what is installed where, use `npm ls`.
|
||||
|
||||
#### Publishing
|
||||
|
||||
Upon publishing, npm will look in the `node_modules` folder.
|
||||
If any of the items there are not in the `bundleDependencies` array, then they will not be included in the package tarball.
|
||||
|
||||
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 [`package.json`](/configuring-npm/package-json) for more information.
|
||||
|
||||
### See also
|
||||
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm install](/commands/npm-install)
|
||||
* [npm pack](/commands/npm-pack)
|
||||
* [npm cache](/commands/npm-cache)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [config](/using-npm/config)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
Generated
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: Install
|
||||
section: 5
|
||||
description: Download and install node and npm
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
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.
|
||||
**We strongly recommend using a Node version manager to install Node.js and npm.** 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.
|
||||
|
||||
### Overview
|
||||
|
||||
- [Checking your version of npm and Node.js](#checking-your-version-of-npm-and-nodejs)
|
||||
- [Using a Node version manager to install Node.js and npm](#using-a-node-version-manager-to-install-nodejs-and-npm)
|
||||
- [Using a Node installer to install Node.js and npm](#using-a-node-installer-to-install-nodejs-and-npm)
|
||||
|
||||
### Checking your version of npm and Node.js
|
||||
|
||||
To see if you already have Node.js and npm installed and check the installed version, run the following commands:
|
||||
|
||||
```
|
||||
node -v
|
||||
npm -v
|
||||
```
|
||||
|
||||
### Using a Node version manager to install Node.js and npm
|
||||
|
||||
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.
|
||||
You can [search for them on GitHub](https://github.com/search?q=node+version+manager+archived%3Afalse&type=repositories&ref=advsearch).
|
||||
|
||||
### Using a Node installer to install Node.js and npm
|
||||
|
||||
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.
|
||||
|
||||
* [Node.js installer](https://nodejs.org/en/download/)
|
||||
* [NodeSource installer](https://github.com/nodesource/distributions).
|
||||
If you use Linux, we recommend that you use a NodeSource installer.
|
||||
|
||||
#### macOS or Windows Node installers
|
||||
|
||||
If you're using macOS or Windows, use one of the installers from the [Node.js download page](https://nodejs.org/en/download/).
|
||||
Be sure to install the version labeled **LTS**. Other versions have not yet been tested with npm.
|
||||
|
||||
#### Linux or other operating systems Node installers
|
||||
|
||||
If you're using Linux or another operating system, use one of the following installers:
|
||||
|
||||
- [NodeSource installer](https://github.com/nodesource/distributions) (recommended)
|
||||
- One of the installers on the [Node.js download page](https://nodejs.org/en/download/)
|
||||
|
||||
Or see [this page](https://nodejs.org/en/download/package-manager/) to install npm for Linux in the way many Linux developers prefer.
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: npm-shrinkwrap.json
|
||||
section: 5
|
||||
description: A publishable lockfile
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
`npm-shrinkwrap.json` is a file created by [`npm shrinkwrap`](/commands/npm-shrinkwrap).
|
||||
It is identical to `package-lock.json`, with one major caveat: Unlike `package-lock.json`,
|
||||
`npm-shrinkwrap.json` may be included when publishing a package.
|
||||
|
||||
The recommended use-case for `npm-shrinkwrap.json` is applications deployed through the publishing process on the registry: for example, daemons and command-line tools intended as global installs or `devDependencies`.
|
||||
It's strongly discouraged for library authors to publish this file, since that would prevent end users from having control over transitive dependency updates.
|
||||
|
||||
If both `package-lock.json` and `npm-shrinkwrap.json` are present in a package root, `npm-shrinkwrap.json` will be preferred over the `package-lock.json` file.
|
||||
|
||||
For full details and description of the `npm-shrinkwrap.json` file format, refer to the manual page for [package-lock.json](/configuring-npm/package-lock-json).
|
||||
|
||||
### See also
|
||||
|
||||
* [npm shrinkwrap](/commands/npm-shrinkwrap)
|
||||
* [package-lock.json](/configuring-npm/package-lock-json)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm install](/commands/npm-install)
|
||||
Generated
Vendored
+193
@@ -0,0 +1,193 @@
|
||||
---
|
||||
title: .npmrc
|
||||
section: 5
|
||||
description: The npm config files
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
npm gets its config settings from the command line, environment variables, and `npmrc` files.
|
||||
|
||||
The `npm config` command can be used to update and edit the contents of the user and global npmrc files.
|
||||
|
||||
For a list of available configuration options, see [config](/using-npm/config).
|
||||
|
||||
### Files
|
||||
|
||||
The four relevant files are:
|
||||
|
||||
* per-project config file (`/path/to/my/project/.npmrc`)
|
||||
* per-user config file (`~/.npmrc`)
|
||||
* global config file (`$PREFIX/etc/npmrc`)
|
||||
* npm builtin config file (`/path/to/npm/npmrc`)
|
||||
|
||||
All npm config files are an ini-formatted list of `key = value` parameters.
|
||||
Environment variables can be replaced using `${VARIABLE_NAME}`.
|
||||
By default if the variable is not defined, it is left unreplaced.
|
||||
By adding `?` after variable name they can be forced to evaluate to an empty string instead.
|
||||
For example:
|
||||
|
||||
```bash
|
||||
cache = ${HOME}/.npm-packages
|
||||
node-options = "${NODE_OPTIONS?} --use-system-ca"
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
Array values are specified by adding "[]" after the key name.
|
||||
For example:
|
||||
|
||||
```bash
|
||||
key[] = "first value"
|
||||
key[] = "second value"
|
||||
```
|
||||
|
||||
#### Comments
|
||||
|
||||
Lines in `.npmrc` files are interpreted as comments when they begin with a
|
||||
`;` or `#` character.
|
||||
`.npmrc` files are parsed by
|
||||
[npm/ini](https://github.com/npm/ini), which specifies this comment syntax.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
# last modified: 01 Jan 2016
|
||||
; Set a new registry for a scoped package
|
||||
@myscope:registry=https://mycustomregistry.example.org
|
||||
```
|
||||
|
||||
#### Per-project config file
|
||||
|
||||
When working locally in a project, a `.npmrc` file in the root of the project (ie, a sibling of `node_modules` and `package.json`) will set config values specific to this project.
|
||||
|
||||
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.
|
||||
|
||||
Additionally, this file is not read in global mode, such as when running `npm install -g`.
|
||||
|
||||
#### Per-user config file
|
||||
|
||||
`$HOME/.npmrc` (or the `userconfig` param, if set in the environment or on the command line)
|
||||
|
||||
#### Global config file
|
||||
|
||||
`$PREFIX/etc/npmrc` (or the `globalconfig` param, if set above): This file is an ini-file formatted list of `key = value` parameters.
|
||||
Environment variables can be replaced as above.
|
||||
|
||||
#### Built-in config file
|
||||
|
||||
`path/to/npm/itself/npmrc`
|
||||
|
||||
This is an unchangeable "builtin" configuration file that npm keeps consistent across updates.
|
||||
Set fields in here using the `./configure` script that comes with npm.
|
||||
This is primarily for distribution maintainers to override default configs in a standard and consistent manner.
|
||||
|
||||
### Auth related configuration
|
||||
|
||||
The settings `_auth`, `_authToken`, `username`, `_password`, `certfile`, and `keyfile` must all be scoped to a specific registry.
|
||||
This ensures that `npm` will never send credentials to the wrong host.
|
||||
|
||||
The full list is:
|
||||
- `_auth` (base64 authentication string)
|
||||
- `_authToken` (authentication token)
|
||||
- `username`
|
||||
- `_password`
|
||||
- `email`
|
||||
- `cafile` (path to certificate authority file)
|
||||
- `certfile` (path to certificate file)
|
||||
- `keyfile` (path to key file)
|
||||
|
||||
In order to scope these values, they must be prefixed by a URI fragment.
|
||||
If the credential is meant for any request to a registry on a single host, the scope may look like `//registry.npmjs.org/:`.
|
||||
If it must be scoped to a specific path on the host that path may also be provided, such as
|
||||
`//my-custom-registry.org/unique/path:`.
|
||||
|
||||
### Unsupported Custom Configuration Keys
|
||||
|
||||
Starting in npm v11.2.0, npm warns when unknown configuration keys are defined in `.npmrc`. In a future major version of npm, these unknown keys may no longer be accepted.
|
||||
|
||||
Only configuration keys that npm officially supports are recognized. Custom keys intended for third-party tools (for example, `electron-builder`) should not be placed in `.npmrc`.
|
||||
|
||||
If you need package-level configuration for use in scripts, use the `config` field in your `package.json` instead:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-package",
|
||||
"config": {
|
||||
"mirror": "https://example.com/"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Values defined in `package.json#config` are exposed to scripts as environment variables prefixed with `npm_package_config_`. For example:
|
||||
|
||||
```
|
||||
npm_package_config_mirror
|
||||
```
|
||||
|
||||
If you need to pass arguments to a script command, use `--` to separate npm arguments from script arguments:
|
||||
|
||||
```
|
||||
npm run build -- --customFlag
|
||||
```
|
||||
|
||||
Using environment variables is also recommended for cross-platform configuration instead of defining unsupported keys in `.npmrc`.
|
||||
|
||||
|
||||
```
|
||||
; bad config
|
||||
_authToken=MYTOKEN
|
||||
|
||||
; good config
|
||||
@myorg:registry=https://somewhere-else.com/myorg
|
||||
@another:registry=https://somewhere-else.com/another
|
||||
//registry.npmjs.org/:_authToken=MYTOKEN
|
||||
|
||||
; would apply to both @myorg and @another
|
||||
//somewhere-else.com/:_authToken=MYTOKEN
|
||||
|
||||
; would apply only to @myorg
|
||||
//somewhere-else.com/myorg/:_authToken=MYTOKEN1
|
||||
|
||||
; would apply only to @another
|
||||
//somewhere-else.com/another/:_authToken=MYTOKEN2
|
||||
```
|
||||
|
||||
### Custom / third-party config keys
|
||||
|
||||
npm only recognizes its own [configuration options](/using-npm/config).
|
||||
If your `.npmrc` contains keys that are not part of npm's config definitions
|
||||
(for example, `electron_mirror` or `sass_binary_site`), npm will emit a
|
||||
warning:
|
||||
|
||||
```
|
||||
warn Unknown user config "electron_mirror".
|
||||
This will stop working in the next major version of npm.
|
||||
```
|
||||
|
||||
These keys were historically tolerated but are not officially supported.
|
||||
A future major version of npm will treat unknown top-level keys as errors.
|
||||
|
||||
Some tools (such as `@electron/get` or `node-sass`) read their own
|
||||
configuration from environment variables or from `.npmrc` by convention.
|
||||
You can set these values as environment variables instead:
|
||||
|
||||
```bash
|
||||
export ELECTRON_MIRROR="https://mirrorexample.npmjs.org/mirrors/electron/"
|
||||
export ELECTRON_CUSTOM_DIR="{{ version }}"
|
||||
```
|
||||
|
||||
Environment variables are the most portable approach and work regardless
|
||||
of `.npmrc` format.
|
||||
|
||||
### See also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/commands/npm-config)
|
||||
* [config](/using-npm/config)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm](/commands/npm)
|
||||
Generated
Vendored
+1195
File diff suppressed because it is too large.
Load diff
Generated
Vendored
+182
@@ -0,0 +1,182 @@
|
||||
---
|
||||
title: package-lock.json
|
||||
section: 5
|
||||
description: A manifestation of the manifest
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
`package-lock.json` is automatically generated for any operations where npm modifies either the `node_modules` tree, or `package.json`.
|
||||
It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
|
||||
|
||||
This file is intended to be committed into source repositories, and serves various purposes:
|
||||
|
||||
* Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
|
||||
|
||||
* Provide a facility for users to "time-travel" to previous states of `node_modules` without having to commit the directory itself.
|
||||
|
||||
* Facilitate greater visibility of tree changes through readable source control diffs.
|
||||
|
||||
* Optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.
|
||||
|
||||
* As of npm v7, lockfiles include enough information to gain a complete picture of the package tree, reducing the need to read `package.json` files, and allowing for significant performance improvements.
|
||||
|
||||
When `npm` creates or updates `package-lock.json`, it will infer line endings and indentation from `package.json` so that the formatting of both files matches.
|
||||
|
||||
### `package-lock.json` vs `npm-shrinkwrap.json`
|
||||
|
||||
Both of these files have the same format, and perform similar functions in the root of a project.
|
||||
|
||||
The difference is that `package-lock.json` cannot be published, and it will be ignored if found in any place other than the root project.
|
||||
|
||||
In contrast, [npm-shrinkwrap.json](/configuring-npm/npm-shrinkwrap-json) allows publication, and defines the dependency tree from the point encountered.
|
||||
This is not recommended unless deploying a CLI tool or otherwise using the publication process for producing production packages.
|
||||
|
||||
If both `package-lock.json` and `npm-shrinkwrap.json` are present in the root of a project, `npm-shrinkwrap.json` will take precedence and `package-lock.json` will be ignored.
|
||||
|
||||
### Hidden Lockfiles
|
||||
|
||||
In order to avoid processing the `node_modules` folder repeatedly, npm as of v7 uses a "hidden" lockfile present in `node_modules/.package-lock.json`.
|
||||
This contains information about the tree, and is used in lieu of reading the entire `node_modules` hierarchy provided that the following conditions are met:
|
||||
|
||||
- All package folders it references exist in the `node_modules` hierarchy.
|
||||
- No package folders exist in the `node_modules` hierarchy that are not listed in the lockfile.
|
||||
- The modified time of the file is at least as recent as all of the package folders it references.
|
||||
|
||||
That is, the hidden lockfile will only be relevant if it was created as part of the most recent update to the package tree.
|
||||
If another CLI mutates the tree in any way, this will be detected, and the hidden lockfile will be ignored.
|
||||
|
||||
Note that it _is_ possible to manually change the _contents_ of a package in such a way that the modified time of the package folder is unaffected.
|
||||
For example, if you add a file to `node_modules/foo/lib/bar.js`, then the modified time on `node_modules/foo` will not reflect this change.
|
||||
If you are manually editing files in `node_modules`, it is generally best to delete the file at `node_modules/.package-lock.json`.
|
||||
|
||||
As the hidden lockfile is ignored by older npm versions, it does not contain the backwards compatibility affordances present in "normal" lockfiles.
|
||||
That is, it is `lockfileVersion: 3`, rather than `lockfileVersion: 2`.
|
||||
|
||||
### Handling Old Lockfiles
|
||||
|
||||
When npm detects a lockfile from npm v6 or before during the package installation process, it is automatically updated to fetch missing information from either the `node_modules` tree or (in the case of empty `node_modules` trees or very old lockfile formats) the npm registry.
|
||||
|
||||
### File Format
|
||||
|
||||
#### `name`
|
||||
|
||||
The name of the package this is a package-lock for.
|
||||
This will match what's in `package.json`.
|
||||
|
||||
#### `version`
|
||||
|
||||
The version of the package this is a package-lock for.
|
||||
This will match what's in `package.json`.
|
||||
|
||||
#### `lockfileVersion`
|
||||
|
||||
An integer version, starting at `1` with the version number of this document whose semantics were used when generating this `package-lock.json`.
|
||||
|
||||
Note that the file format changed significantly in npm v7 to track information that would have otherwise required looking in `node_modules` or the npm registry.
|
||||
Lockfiles generated by npm v7 will contain `lockfileVersion: 2`.
|
||||
|
||||
* No version provided: an "ancient" shrinkwrap file from a version of npm prior to npm v5.
|
||||
* `1`: The lockfile version used by npm v5 and v6.
|
||||
* `2`: The lockfile version used by npm v7 and v8. Backwards compatible to v1 lockfiles.
|
||||
* `3`: The lockfile version used by npm v9 and above.
|
||||
Backwards compatible to npm v7.
|
||||
|
||||
npm will always attempt to get whatever data it can out of a lockfile, even if it is not a version that it was designed to support.
|
||||
|
||||
#### `packages`
|
||||
|
||||
This is an object that maps package locations to an object containing the information about that package.
|
||||
|
||||
The root project is typically listed with a key of `""`, and all other packages are listed with their relative paths from the root project folder.
|
||||
|
||||
Package descriptors have the following fields:
|
||||
|
||||
* version: The version found in `package.json`
|
||||
|
||||
* resolved: The place where the package was actually resolved from.
|
||||
In the case of packages fetched from the registry, this will be a url to a tarball.
|
||||
In the case of git dependencies, this will be the full git url with commit sha.
|
||||
In the case of link dependencies, this will be the location of the link target.
|
||||
`registry.npmjs.org` is a magic value meaning "the currently configured registry".
|
||||
|
||||
* integrity: A `sha512` or `sha1` [Standard Subresource Integrity](https://w3c.github.io/webappsec/specs/subresourceintegrity/) string for the artifact that was unpacked in this location.
|
||||
|
||||
* link: A flag to indicate that this is a symbolic link.
|
||||
If this is present, no other fields are specified, since the link target will also be included in the lockfile.
|
||||
|
||||
* dev, optional, devOptional: If the package is strictly part of the
|
||||
`devDependencies` tree, then `dev` will be true.
|
||||
If it is strictly part of the `optionalDependencies` tree, then `optional` will be set.
|
||||
If it is both a `dev` dependency _and_ an `optional` dependency of a non-dev dependency, then `devOptional` will be set.
|
||||
(An `optional` dependency of a `dev` dependency will have both `dev` and `optional` set.)
|
||||
|
||||
* inBundle: A flag to indicate that the package is a bundled dependency.
|
||||
|
||||
* hasInstallScript: A flag to indicate that the package has a `preinstall`, `install`, or `postinstall` script.
|
||||
|
||||
* hasShrinkwrap: A flag to indicate that the package has an `npm-shrinkwrap.json` file.
|
||||
|
||||
* bin, license, engines, dependencies, optionalDependencies: fields from `package.json`
|
||||
|
||||
* os: An array of operating systems this package is compatible with, as specified in `package.json`. This field is included when the package specifies OS restrictions.
|
||||
|
||||
* cpu: An array of CPU architectures this package is compatible with, as specified in `package.json`. This field is included when the package specifies CPU restrictions.
|
||||
|
||||
* funding: Funding information for the package, as specified in `package.json`. This field contains details about how to support the package maintainers.
|
||||
|
||||
#### dependencies
|
||||
|
||||
Legacy data for supporting versions of npm that use `lockfileVersion: 1`.
|
||||
This is a mapping of package names to dependency objects.
|
||||
Because the object structure is strictly hierarchical, symbolic link dependencies are somewhat challenging to represent in some cases.
|
||||
|
||||
npm v7 ignores this section entirely if a `packages` section is present, but does keep it up to date in order to support switching between npm v6 and npm v7.
|
||||
|
||||
Dependency objects have the following fields:
|
||||
|
||||
* version: a specifier that varies depending on the nature of the package, and is usable in fetching a new copy of it.
|
||||
Note that for peer dependencies that are not installed, or optional dependencies that are not installed, this field may be omitted.
|
||||
|
||||
* bundled dependencies: Regardless of source, this is a version number that is purely for informational purposes.
|
||||
* registry sources: This is a version number.
|
||||
(eg, `1.2.3`)
|
||||
* git sources: This is a git specifier with resolved committish.
|
||||
(eg, `git+https://example.com/foo/bar#115311855adb0789a0466714ed48a1499ffea97e`)
|
||||
* http tarball sources: This is the URL of the tarball.
|
||||
(eg, `https://example.com/example-1.3.0.tgz`)
|
||||
* local tarball sources: This is the file URL of the tarball.
|
||||
(eg `file:///opt/storage/example-1.3.0.tgz`)
|
||||
* local link sources: This is the file URL of the link.
|
||||
(eg `file:libs/our-module`)
|
||||
|
||||
**Note:** The `version` field may be omitted for certain types of dependencies, such as optional peer dependencies that are not installed. In these cases, only metadata fields like `dev`, `optional`, and `peer` will be present.
|
||||
|
||||
* integrity: A `sha512` or `sha1` [Standard Subresource Integrity](https://w3c.github.io/webappsec/specs/subresourceintegrity/) string for the artifact that was unpacked in this location.
|
||||
For git dependencies, this is the commit sha.
|
||||
|
||||
* resolved: 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.
|
||||
`registry.npmjs.org` is a magic value meaning "the currently configured registry".
|
||||
|
||||
* bundled: 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.
|
||||
|
||||
* dev: 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.
|
||||
|
||||
* optional: 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.
|
||||
|
||||
* requires: 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 `dependencies` or in a level higher than us.
|
||||
|
||||
* dependencies: The dependencies of this dependency, exactly as at the top level.
|
||||
|
||||
### See also
|
||||
|
||||
* [npm shrinkwrap](/commands/npm-shrinkwrap)
|
||||
* [npm-shrinkwrap.json](/configuring-npm/npm-shrinkwrap-json)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm install](/commands/npm-install)
|
||||
+2347
File diff suppressed because it is too large.
Load diff
Generated
Vendored
+247
@@ -0,0 +1,247 @@
|
||||
---
|
||||
title: Dependency Selectors
|
||||
section: 7
|
||||
description: Dependency Selector Syntax & Querying
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
The [`npm query`](/commands/npm-query) command exposes a new dependency selector syntax (informed by & respecting many aspects of the [CSS Selectors 4 Spec](https://dev.w3.org/csswg/selectors4/#relational)) which:
|
||||
|
||||
- Standardizes the shape of, & querying of, dependency graphs with a robust object model, metadata & selector syntax
|
||||
- Leverages existing, known language syntax & operators from CSS to make disparate package information broadly accessible
|
||||
- Unlocks the ability to answer complex, multi-faceted questions about dependencies, their relationships & associative metadata
|
||||
- Consolidates redundant logic of similar query commands in `npm` (ex.
|
||||
`npm fund`, `npm ls`, `npm outdated`, `npm audit` ...)
|
||||
|
||||
### Dependency Selector Syntax
|
||||
|
||||
#### Overview:
|
||||
|
||||
- there is no "type" or "tag" selectors (ex.
|
||||
`div, h1, a`) as a dependency/target is the only type of `Node` that can be queried
|
||||
- the term "dependencies" is in reference to any `Node` found in a `tree` returned by `Arborist`
|
||||
|
||||
#### Combinators
|
||||
|
||||
- `>` direct descendant/child
|
||||
- ` ` any descendant/child
|
||||
- `~` sibling
|
||||
|
||||
#### Selectors
|
||||
|
||||
- `*` universal selector
|
||||
- `#<name>` dependency selector (equivalent to `[name="..."]`)
|
||||
- `#<name>@<version>` (equivalent to `[name=<name>]:semver(<version>)`)
|
||||
- `,` selector list delimiter
|
||||
- `.` dependency type selector
|
||||
- `:` pseudo selector
|
||||
|
||||
#### Dependency Type Selectors
|
||||
|
||||
- `.prod` dependency found in the `dependencies` section of `package.json`, or is a child of said dependency
|
||||
- `.dev` dependency found in the `devDependencies` section of `package.json`, or is a child of said dependency
|
||||
- `.optional` dependency found in the `optionalDependencies` section of `package.json`, or has `"optional": true` set in its entry in the `peerDependenciesMeta` section of `package.json`, or a child of said dependency
|
||||
- `.peer` dependency found in the `peerDependencies` section of `package.json`
|
||||
- `.workspace` dependency found in the [`workspaces`](https://docs.npmjs.com/cli/v8/using-npm/workspaces) section of `package.json`
|
||||
- `.bundled` dependency found in the `bundleDependencies` section of `package.json`, or is a child of said dependency
|
||||
|
||||
#### Pseudo Selectors
|
||||
- [`:not(<selector>)`](https://developer.mozilla.org/en-US/docs/Web/CSS/:not)
|
||||
- [`:has(<selector>)`](https://developer.mozilla.org/en-US/docs/Web/CSS/:has)
|
||||
- [`:is(<selector list>)`](https://developer.mozilla.org/en-US/docs/Web/CSS/:is)
|
||||
- [`:root`](https://developer.mozilla.org/en-US/docs/Web/CSS/:root) matches the root node/dependency
|
||||
- [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) matches node/dependency it was queried against
|
||||
- [`:empty`](https://developer.mozilla.org/en-US/docs/Web/CSS/:empty) when a dependency has no dependencies
|
||||
- [`:private`](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#private) when a dependency is private
|
||||
- `:link` when a dependency is linked (for instance, workspaces or packages manually [`linked`](https://docs.npmjs.com/cli/v8/commands/npm-link)
|
||||
- `:deduped` when a dependency has been deduped (note that this does *not* always mean the dependency has been hoisted to the root of node_modules)
|
||||
- `:overridden` when a dependency has been overridden
|
||||
- `:extraneous` when a dependency exists but is not defined as a dependency of any node
|
||||
- `:invalid` when a dependency version is out of its ancestors specified range
|
||||
- `:missing` when a dependency is not found on disk
|
||||
- `:semver(<spec>, [selector], [function])` match a valid [`node-semver`](https://github.com/npm/node-semver) version or range to a selector
|
||||
- `:path(<path>)` [glob](https://www.npmjs.com/package/glob) matching based on dependencies path relative to the project
|
||||
- `:type(<type>)` [based on currently recognized types](https://github.com/npm/npm-package-arg#result-object). You can also use the aggregate type of `registry` for any registry dependency (e.g. tag, version, range, alias)
|
||||
- `:outdated(<type>)` when a dependency is outdated
|
||||
- `:vuln(<selector>)` when a dependency has a known vulnerability
|
||||
|
||||
##### `:semver(<spec>, [selector], [function])`
|
||||
|
||||
The `:semver()` pseudo selector allows comparing fields from each node's `package.json` using [semver](https://github.com/npm/node-semver#readme) methods.
|
||||
It accepts up to 3 parameters, all but the first of which are optional.
|
||||
|
||||
- `spec` a semver version or range
|
||||
- `selector` an attribute selector for each node (default `[version]`)
|
||||
- `function` a semver method to apply, one of: `satisfies`, `intersects`, `subset`, `gt`, `gte`, `gtr`, `lt`, `lte`, `ltr`, `eq`, `neq` or the special function `infer` (default `infer`)
|
||||
|
||||
When the special `infer` function is used the `spec` and the actual value from the node are compared.
|
||||
If both are versions, according to `semver.valid()`, `eq` is used.
|
||||
If both values are ranges, according to `!semver.valid()`, `intersects` is used.
|
||||
If the values are mixed types `satisfies` is used.
|
||||
|
||||
Some examples:
|
||||
|
||||
- `:semver(^1.0.0)` returns every node that has a `version` satisfied by the provided range `^1.0.0`
|
||||
- `:semver(16.0.0, :attr(engines, [node]))` returns every node which has an `engines.node` property satisfying the version `16.0.0`
|
||||
- `:semver(1.0.0, [version], lt)` every node with a `version` less than `1.0.0`
|
||||
|
||||
##### `:outdated(<type>)`
|
||||
|
||||
The `:outdated` pseudo selector retrieves data from the registry and returns information about which of your dependencies are outdated.
|
||||
The type parameter may be one of the following:
|
||||
|
||||
- `any` (default) a version exists that is greater than the current one
|
||||
- `in-range` a version exists that is greater than the current one, and satisfies at least one if its parent's dependencies
|
||||
- `out-of-range` a version exists that is greater than the current one, does not satisfy at least one of its parent's dependencies
|
||||
- `major` a version exists that is a semver major greater than the current one
|
||||
- `minor` a version exists that is a semver minor greater than the current one
|
||||
- `patch` a version exists that is a semver patch greater than the current one
|
||||
|
||||
In addition to the filtering performed by the pseudo selector, some extra data is added to the resulting objects.
|
||||
The following data can be found under the `queryContext` property of each node.
|
||||
|
||||
- `versions` an array of every available version of the given node
|
||||
- `outdated.inRange` an array of objects, each with a `from` and `versions`, where `from` is the on-disk location of the node that depends on the current node and `versions` is an array of all available versions that satisfies that dependency.
|
||||
This is only populated if `:outdated(in-range)` is used.
|
||||
- `outdated.outOfRange` an array of objects, identical in shape to `inRange`, but where the `versions` array is every available version that does not satisfy the dependency.
|
||||
This is only populated if `:outdated(out-of-range)` is used.
|
||||
|
||||
Some examples:
|
||||
|
||||
- `:root > :outdated(major)` returns every direct dependency that has a new semver major release
|
||||
- `.prod:outdated(in-range)` returns production dependencies that have a new release that satisfies at least one of its parent's dependencies
|
||||
|
||||
##### `:vuln`
|
||||
|
||||
The `:vuln` pseudo selector retrieves data from the registry and returns information about which if your dependencies has a known vulnerability.
|
||||
Only dependencies whose current version matches a vulnerability will be returned.
|
||||
For example if you have `semver@7.6.0` in your tree, a vulnerability for `semver` which affects versions `<=6.3.1` will not match.
|
||||
|
||||
You can also filter results by certain attributes in advisories.
|
||||
Currently that includes `severity` and `cwe`.
|
||||
Note that severity filtering is done per severity, it does not include severities "higher" or "lower" than the one specified.
|
||||
|
||||
In addition to the filtering performed by the pseudo selector, info about each relevant advisory will be added to the `queryContext` attribute of each node under the `advisories` attribute.
|
||||
|
||||
Some examples:
|
||||
|
||||
- `:root > .prod:vuln` returns direct production dependencies with any known vulnerability
|
||||
- `:vuln([severity=high])` returns only dependencies with a vulnerability with a `high` severity.
|
||||
- `:vuln([severity=high],[severity=moderate])` returns only dependencies with a vulnerability with a `high` or `moderate` severity.
|
||||
- `:vuln([cwe=1333])` returns only dependencies with a vulnerability that includes CWE-1333 (ReDoS)
|
||||
|
||||
#### [Attribute Selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)
|
||||
|
||||
The attribute selector evaluates the key/value pairs in `package.json` if they are `String`s.
|
||||
|
||||
- `[]` attribute selector (ie.
|
||||
existence of attribute)
|
||||
- `[attribute=value]` attribute value is equivalent...
|
||||
- `[attribute~=value]` attribute value contains word...
|
||||
- `[attribute*=value]` attribute value contains string...
|
||||
- `[attribute|=value]` attribute value is equal to or starts with...
|
||||
- `[attribute^=value]` attribute value starts with...
|
||||
- `[attribute$=value]` attribute value ends with...
|
||||
|
||||
#### `Array` & `Object` Attribute Selectors
|
||||
|
||||
The generic `:attr()` pseudo selector standardizes a pattern which can be used for attribute selection of `Object`s, `Array`s or `Arrays` of `Object`s accessible via `Arborist`'s `Node.package` metadata.
|
||||
This allows for iterative attribute selection beyond top-level `String` evaluation.
|
||||
The last argument passed to `:attr()` must be an `attribute` selector or a nested `:attr()`.
|
||||
See examples below:
|
||||
|
||||
#### `Objects`
|
||||
|
||||
```css
|
||||
/* return dependencies that have a `scripts.test` containing `"tap"` */
|
||||
*:attr(scripts, [test~=tap])
|
||||
```
|
||||
|
||||
#### Nested `Objects`
|
||||
|
||||
Nested objects are expressed as sequential arguments to `:attr()`.
|
||||
|
||||
```css
|
||||
/* return dependencies that have a [testling config](https://ci.testling.com/guide/advanced_configuration) for opera browsers */
|
||||
*:attr(testling, browsers, [~=opera])
|
||||
```
|
||||
|
||||
#### `Arrays`
|
||||
|
||||
`Array`s specifically uses a special/reserved `.` character in place of a typical attribute name.
|
||||
`Arrays` also support exact `value` matching when a `String` is passed to the selector.
|
||||
|
||||
##### Example of an `Array` Attribute Selection:
|
||||
```css
|
||||
/* removes the distinction between properties & arrays */
|
||||
/* ie. we'd have to check the property & iterate to match selection */
|
||||
*:attr([keywords^=react])
|
||||
*:attr(contributors, :attr([name~=Jordan]))
|
||||
```
|
||||
|
||||
##### Example of an `Array` matching directly to a value:
|
||||
```css
|
||||
/* return dependencies that have the exact keyword "react" */
|
||||
/* this is equivalent to `*:keywords([value="react"])` */
|
||||
*:attr([keywords=react])
|
||||
```
|
||||
|
||||
##### Example of an `Array` of `Object`s:
|
||||
```css
|
||||
/* returns */
|
||||
*:attr(contributors, [email=ruyadorno@github.com])
|
||||
```
|
||||
|
||||
### Groups
|
||||
|
||||
Dependency groups are defined by the package relationships to their ancestors (ie.
|
||||
the dependency types that are defined in `package.json`).
|
||||
This approach is user-centric as the ecosystem has been taught to think about dependencies in these groups first-and-foremost.
|
||||
Dependencies are allowed to be included in multiple groups (ex.
|
||||
a `prod` dependency may also be a `dev` dependency (in that it's also required by another `dev` dependency) & may also be `bundled` - a selector for that type of dependency would look like: `*.prod.dev.bundled`).
|
||||
|
||||
- `.prod`
|
||||
- `.dev`
|
||||
- `.optional`
|
||||
- `.peer`
|
||||
- `.bundled`
|
||||
- `.workspace`
|
||||
|
||||
Please note that currently `workspace` deps are always `prod` dependencies.
|
||||
Additionally the `.root` dependency is also considered a `prod` dependency.
|
||||
|
||||
### Programmatic Usage
|
||||
|
||||
- `Arborist`'s `Node` Class has a `.querySelectorAll()` method
|
||||
- this method will return a filtered, flattened dependency Arborist `Node` list based on a valid query selector
|
||||
|
||||
```js
|
||||
const Arborist = require('@npmcli/arborist')
|
||||
const arb = new Arborist({})
|
||||
```
|
||||
|
||||
```js
|
||||
// root-level
|
||||
arb.loadActual().then(async (tree) => {
|
||||
// query all production dependencies
|
||||
const results = await tree.querySelectorAll('.prod')
|
||||
console.log(results)
|
||||
})
|
||||
```
|
||||
|
||||
```js
|
||||
// iterative
|
||||
arb.loadActual().then(async (tree) => {
|
||||
// query for the deduped version of react
|
||||
const results = await tree.querySelectorAll('#react:not(:deduped)')
|
||||
// query the deduped react for git deps
|
||||
const deps = await results[0].querySelectorAll(':type(git)')
|
||||
console.log(deps)
|
||||
})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [npm query](/commands/npm-query)
|
||||
* [@npmcli/arborist](https://npm.im/@npmcli/arborist)
|
||||
Generated
Vendored
+215
@@ -0,0 +1,215 @@
|
||||
---
|
||||
title: Developers
|
||||
section: 7
|
||||
description: Developer guide
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
So, you've decided to use npm to develop (and maybe publish/deploy) your project.
|
||||
|
||||
Fantastic!
|
||||
|
||||
There are a few things that you need to do above the simple steps that your users will do to install your program.
|
||||
|
||||
### About These Documents
|
||||
|
||||
These are man pages.
|
||||
If you install npm, you should be able to then do `man npm-thing` to get the documentation on a particular topic, or `npm help thing` to see the same information.
|
||||
|
||||
### What is a Package
|
||||
|
||||
A package is:
|
||||
|
||||
* a) a folder containing a program described by a package.json file
|
||||
* b) a gzipped tarball containing (a)
|
||||
* c) a url that resolves to (b)
|
||||
* d) a `<name>@<version>` that is published on the registry with (c)
|
||||
* e) a `<name>@<tag>` that points to (d)
|
||||
* f) a `<name>` that has a "latest" tag satisfying (e)
|
||||
* g) a `git` url that, when cloned, results in (a).
|
||||
|
||||
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).
|
||||
|
||||
Git urls can be of the form:
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
The `commit-ish` can be any tag, sha, or branch which can be supplied as an argument to `git checkout`.
|
||||
The default is whatever the repository uses as its default branch.
|
||||
|
||||
### The package.json File
|
||||
|
||||
You need to have a `package.json` file in the root of your project to do much of anything with npm.
|
||||
That is basically the whole interface.
|
||||
|
||||
See [`package.json`](/configuring-npm/package-json) for details about what goes in that file.
|
||||
At the very least, you need:
|
||||
|
||||
* 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, `node-foo` and `bar-js` are bad names.
|
||||
`foo` or `bar` are better.
|
||||
|
||||
* version: A semver-compatible version.
|
||||
|
||||
* 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.
|
||||
|
||||
* author: Take some credit.
|
||||
|
||||
* scripts: If you have a special compilation or installation script, then you should put it in the `scripts` object.
|
||||
You should definitely have at least a basic smoke-test command as the "scripts.test" field.
|
||||
See [scripts](/using-npm/scripts).
|
||||
|
||||
* 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.
|
||||
|
||||
* 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.
|
||||
|
||||
You can use `npm init` in the root of your package in order to get you started with a pretty basic package.json file.
|
||||
See [`npm init`](/commands/npm-init) for more info.
|
||||
|
||||
### Keeping files *out* of your Package
|
||||
|
||||
Use a `.npmignore` file to keep stuff out of your package.
|
||||
If there's no `.npmignore` file, but there *is* a `.gitignore` file, then npm will ignore the stuff matched by the `.gitignore` file.
|
||||
If you *want* to include something that is excluded by your `.gitignore` file, you can create an empty `.npmignore` file to override it.
|
||||
Like `git`, `npm` looks for `.npmignore` and `.gitignore` files in all subdirectories of your package, not only the root directory.
|
||||
|
||||
`.npmignore` files follow the [same pattern rules](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring) as `.gitignore` files:
|
||||
|
||||
* Blank lines or lines starting with `#` are ignored.
|
||||
* Standard glob patterns work.
|
||||
* You can end patterns with a forward slash `/` to specify a directory.
|
||||
* You can negate a pattern by starting it with an exclamation point `!`.
|
||||
|
||||
By default, some paths and files are ignored, so there's no need to add them to `.npmignore` explicitly.
|
||||
Some examples are:
|
||||
|
||||
* `.*.swp`
|
||||
* `._*`
|
||||
* `.DS_Store`
|
||||
* `.git`
|
||||
* `.gitignore`
|
||||
* `.hg`
|
||||
* `.npmignore`
|
||||
* `.npmrc`
|
||||
* `.lock-wscript`
|
||||
* `.svn`
|
||||
* `.wafpickle-*`
|
||||
* `config.gypi`
|
||||
* `CVS`
|
||||
* `npm-debug.log`
|
||||
|
||||
Additionally, everything in `node_modules` is ignored, except for bundled dependencies.
|
||||
npm automatically handles this for you, so don't bother adding `node_modules` to `.npmignore`.
|
||||
|
||||
The following paths and files are never ignored, so adding them to `.npmignore` is pointless:
|
||||
|
||||
* `package.json`
|
||||
* `README` (and its variants)
|
||||
* `LICENSE` / `LICENCE`
|
||||
|
||||
If, given the structure of your project, you find `.npmignore` to be a maintenance headache, you might instead try populating the `files` property of `package.json`, which is an array of file or directory names that should be included in your package.
|
||||
Sometimes manually picking which items to allow is easier to manage than building a block list.
|
||||
|
||||
See [`package.json`](/configuring-npm/package-json) for more info on what can and can't be ignored.
|
||||
|
||||
#### Testing whether your `.npmignore` or `files` config works
|
||||
|
||||
If you want to double check that your package will include only the files you intend it to when published, you can run the `npm pack` command locally which will generate a tarball in the working directory, the same way it does for publishing.
|
||||
|
||||
### Link Packages
|
||||
|
||||
`npm link` 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 `npm rebuild -g` to update compiled packages, of course.)
|
||||
|
||||
More info at [`npm link`](/commands/npm-link).
|
||||
|
||||
### Before Publishing: Make Sure Your Package Installs and Works
|
||||
|
||||
**This is important.**
|
||||
|
||||
If you cannot 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.
|
||||
|
||||
In the root of your package, do this:
|
||||
|
||||
```bash
|
||||
npm install . -g
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
npm link
|
||||
```
|
||||
|
||||
Use `npm ls -g` to see if it's there.
|
||||
|
||||
To test a local install, go into some other folder, and then do:
|
||||
|
||||
```bash
|
||||
cd ../some-other-folder
|
||||
npm install ../my-package
|
||||
```
|
||||
|
||||
to install it locally into the node_modules folder in that other place.
|
||||
|
||||
Then go into the node-repl, and try using require("my-thing") to bring in your module's main module.
|
||||
|
||||
### Create a User Account
|
||||
|
||||
Create a user with the adduser command.
|
||||
It works like this:
|
||||
|
||||
```bash
|
||||
npm adduser
|
||||
```
|
||||
|
||||
and then follow the prompts.
|
||||
|
||||
This is documented better in [npm adduser](/commands/npm-adduser).
|
||||
|
||||
### Publish your Package
|
||||
|
||||
This part's easy.
|
||||
In the root of your folder, do this:
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
You can give publish a url to a tarball, or a filename of a tarball, or a path to a folder.
|
||||
|
||||
Note that pretty much **everything in that folder will be exposed** by default.
|
||||
So, if you have secret stuff in there, use a `.npmignore` file to list out the globs to ignore, or publish from a fresh checkout.
|
||||
|
||||
### Brag about it
|
||||
|
||||
Send emails, write blogs, blab in IRC.
|
||||
|
||||
Tell the world how easy it is to install your program!
|
||||
|
||||
### See also
|
||||
|
||||
* [npm](/commands/npm)
|
||||
* [npm init](/commands/npm-init)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm publish](/commands/npm-publish)
|
||||
* [npm adduser](/commands/npm-adduser)
|
||||
* [npm registry](/using-npm/registry)
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
---
|
||||
title: Logging
|
||||
section: 7
|
||||
description: Why, What & How we Log
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
The `npm` CLI has various mechanisms for showing different levels of information back to end-users for certain commands, configurations & environments.
|
||||
|
||||
### Setting Log File Location
|
||||
|
||||
All logs are written to a debug log, with the path to that file printed if the execution of a command fails.
|
||||
|
||||
The default location of the logs directory is a directory named `_logs` inside the npm cache.
|
||||
This can be changed with the `logs-dir` config option.
|
||||
|
||||
For example, if you wanted to write all your logs to the current working directory, you could run: `npm install --logs-dir=.`.
|
||||
This is especially helpful in debugging a specific `npm` issue as you can run a command multiple times with different config values and then diff all the log files.
|
||||
|
||||
Log files will be removed from the `logs-dir` when the number of log files exceeds `logs-max`, with the oldest logs being deleted first.
|
||||
|
||||
To turn off logs completely set `--logs-max=0`.
|
||||
|
||||
### Setting Log Levels
|
||||
|
||||
#### `loglevel`
|
||||
|
||||
`loglevel` is a global argument/config that can be set to determine the type of information to be displayed.
|
||||
|
||||
The default value of `loglevel` is `"notice"` but there are several levels/types of logs available, including:
|
||||
|
||||
- `"silent"`
|
||||
- `"error"`
|
||||
- `"warn"`
|
||||
- `"notice"`
|
||||
- `"http"`
|
||||
- `"info"`
|
||||
- `"verbose"`
|
||||
- `"silly"`
|
||||
|
||||
All logs pertaining to a level preceding the current setting will be shown.
|
||||
|
||||
##### Aliases
|
||||
|
||||
The log levels listed above have various corresponding aliases, including:
|
||||
|
||||
- `-d`: `--loglevel info`
|
||||
- `--dd`: `--loglevel verbose`
|
||||
- `--verbose`: `--loglevel verbose`
|
||||
- `--ddd`: `--loglevel silly`
|
||||
- `-q`: `--loglevel warn`
|
||||
- `--quiet`: `--loglevel warn`
|
||||
- `-s`: `--loglevel silent`
|
||||
- `--silent`: `--loglevel silent`
|
||||
|
||||
#### `foreground-scripts`
|
||||
|
||||
The `npm` CLI began hiding the output of lifecycle scripts for `npm install` as of `v7`.
|
||||
Notably, this means you will not see logs/output from packages that may be using "install scripts" to display information back to you or from your own project's scripts defined in `package.json`.
|
||||
If you'd like to change this behavior & log this output you can set `foreground-scripts` to `true`.
|
||||
|
||||
### Timing Information
|
||||
|
||||
The [`--timing` config](/using-npm/config#timing) can be set which does a few things:
|
||||
|
||||
1. Always shows the full path to the debug log regardless of command exit status
|
||||
1. Write timing information to a process specific timing file in the cache or `logs-dir`
|
||||
1. Output timing information to the terminal
|
||||
|
||||
This file contains a `timers` object where the keys are an identifier for the portion of the process being timed and the value is the number of milliseconds it took to complete.
|
||||
|
||||
Sometimes it is helpful to get timing information without outputting anything to the terminal.
|
||||
For example, the performance might be affected by writing to the terminal.
|
||||
In this case you can use
|
||||
`--timing --silent` which will still write the timing file, but not output anything to the terminal while running.
|
||||
|
||||
### Registry Response Headers
|
||||
|
||||
#### `npm-notice`
|
||||
|
||||
The `npm` CLI reads from & logs any `npm-notice` headers that are returned from the configured registry.
|
||||
This mechanism can be used by third-party registries to provide useful information when network-dependent requests occur.
|
||||
|
||||
This header is not cached, and will not be logged if the request is served from the cache.
|
||||
|
||||
### Logs and Sensitive Information
|
||||
|
||||
The `npm` CLI makes a best effort to redact the following from terminal output and log files:
|
||||
|
||||
- Passwords inside basic auth URLs
|
||||
- npm tokens
|
||||
|
||||
However, this behavior should not be relied on to keep all possible sensitive information redacted.
|
||||
If you are concerned about secrets in your log file or terminal output, you can use `--loglevel=silent` and `--logs-max=0` to ensure no logs are written to your terminal or filesystem.
|
||||
|
||||
### See also
|
||||
|
||||
* [config](/using-npm/config)
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: Organizations
|
||||
section: 7
|
||||
description: Working with teams & organizations
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
There are three levels of org users:
|
||||
|
||||
1. Super admin, controls billing & adding people to the org.
|
||||
2. Team admin, manages team membership & package access.
|
||||
3. Developer, works on packages they are given access to.
|
||||
|
||||
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 `developers` team that all users are automatically added to.
|
||||
|
||||
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.
|
||||
|
||||
The developer will be able to access packages based on the teams they are on.
|
||||
Access is either read-write or read-only.
|
||||
|
||||
There are two main commands:
|
||||
|
||||
1. `npm team` see [npm team](/commands/npm-team) for more details
|
||||
2. `npm access` see [npm access](/commands/npm-access) for more details
|
||||
|
||||
### Team Admins create teams
|
||||
|
||||
* Check who you’ve added to your org:
|
||||
|
||||
```bash
|
||||
npm team ls <org>:developers
|
||||
```
|
||||
|
||||
* Each org is automatically given a `developers` 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 `access` command.
|
||||
|
||||
* Create a new team:
|
||||
|
||||
```bash
|
||||
npm team create <org:team>
|
||||
```
|
||||
|
||||
* Add members to that team:
|
||||
|
||||
```bash
|
||||
npm team add <org:team> <user>
|
||||
```
|
||||
|
||||
### Publish a package and adjust package access
|
||||
|
||||
* In package directory, run
|
||||
|
||||
```bash
|
||||
npm init --scope=<org>
|
||||
```
|
||||
to scope it for your org & publish as usual
|
||||
|
||||
* Grant access:
|
||||
|
||||
```bash
|
||||
npm access grant <read-only|read-write> <org:team> [<package>]
|
||||
```
|
||||
|
||||
* Revoke access:
|
||||
|
||||
```bash
|
||||
npm access revoke <org:team> [<package>]
|
||||
```
|
||||
|
||||
### Monitor your package access
|
||||
|
||||
* See what org packages a team member can access:
|
||||
|
||||
```bash
|
||||
npm access list packages <org> <user>
|
||||
```
|
||||
|
||||
* See packages available to a specific team:
|
||||
|
||||
```bash
|
||||
npm access list packages <org:team>
|
||||
```
|
||||
|
||||
* Check which teams are collaborating on a package:
|
||||
|
||||
```bash
|
||||
npm access list collaborators <pkg>
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
* [npm team](/commands/npm-team)
|
||||
* [npm access](/commands/npm-access)
|
||||
* [npm scope](/using-npm/scope)
|
||||
Generated
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: Package spec
|
||||
section: 7
|
||||
description: Package name specifier
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
Commands like `npm install` and the dependency sections in the `package.json` use a package name specifier.
|
||||
This can be many different things that all refer to a "package". Examples include a package name, git url, tarball, or local directory.
|
||||
These will generally be referred to as `<package-spec>` in the help output for the npm commands that use this package name specifier.
|
||||
|
||||
### Package name
|
||||
|
||||
* `[<@scope>/]<pkg>`
|
||||
* `[<@scope>/]<pkg>@<tag>`
|
||||
* `[<@scope>/]<pkg>@<version>`
|
||||
* `[<@scope>/]<pkg>@<version range>`
|
||||
|
||||
Refers to a package by name, with or without a scope, and optionally tag, version, or version range.
|
||||
This is typically used in combination with the [registry](/using-npm/config#registry) config to refer to a package in a registry.
|
||||
|
||||
Examples:
|
||||
* `npm`
|
||||
* `@npmcli/arborist`
|
||||
* `@npmcli/arborist@latest`
|
||||
* `npm@6.13.1`
|
||||
* `npm@^4.0.0`
|
||||
|
||||
### Aliases
|
||||
|
||||
* `<alias>@npm:<name>`
|
||||
|
||||
Primarily used by commands like `npm install` and in the dependency sections in the `package.json`, this refers to a package by an alias.
|
||||
The `<alias>` is the name of the package as it is reified in the `node_modules` folder, and the `<name>` refers to a package name as found in the configured registry.
|
||||
|
||||
See `Package name` above for more info on referring to a package by name, and [registry](/using-npm/config#registry) for configuring which registry is used when referring to a package by name.
|
||||
|
||||
Examples:
|
||||
* `semver@npm:@npmcli/semver-with-patch`
|
||||
* `semver@npm:semver@7.2.2`
|
||||
* `semver@npm:semver@legacy`
|
||||
|
||||
### Folders
|
||||
|
||||
* `<folder>`
|
||||
|
||||
This refers to a package on the local filesystem.
|
||||
Specifically this is a folder with a `package.json` file in it.
|
||||
This *should* always be prefixed with a `/` or `./` (or your OS equivalent) to reduce confusion.
|
||||
npm currently will parse a string with more than one `/` in it as a folder, but this is legacy behavior that may be removed in a future version.
|
||||
|
||||
Examples:
|
||||
|
||||
* `./my-package`
|
||||
* `/opt/npm/my-package`
|
||||
|
||||
### Tarballs
|
||||
|
||||
* `<tarball file>`
|
||||
* `<tarball url>`
|
||||
|
||||
Examples:
|
||||
|
||||
* `./my-package.tgz`
|
||||
* `https://registry.npmjs.org/semver/-/semver-1.0.0.tgz`
|
||||
|
||||
Refers to a package in a tarball format, either on the local filesystem or remotely via url.
|
||||
This is the format that packages exist in when uploaded to a registry.
|
||||
|
||||
### git urls
|
||||
|
||||
* `<git:// url>`
|
||||
* `<github username>/<github project>`
|
||||
|
||||
Refers to a package in a git repo.
|
||||
This can be a full git url, git shorthand, or a username/package on GitHub.
|
||||
You can specify a git tag, branch, or other git ref by appending `#ref`.
|
||||
|
||||
Examples:
|
||||
|
||||
* `https://github.com/npm/cli.git`
|
||||
* `git@github.com:npm/cli.git`
|
||||
* `git+ssh://git@github.com/npm/cli#v6.0.0`
|
||||
* `github:npm/cli#HEAD`
|
||||
* `npm/cli#c12ea07`
|
||||
|
||||
### See also
|
||||
|
||||
* [npm-package-arg](https://npm.im/npm-package-arg)
|
||||
* [scope](/using-npm/scope)
|
||||
* [config](/using-npm/config)
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: Registry
|
||||
section: 7
|
||||
description: The JavaScript Package Registry
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
To resolve packages by name and version, npm talks to a registry website that implements the CommonJS Package Registry specification for reading package info.
|
||||
|
||||
npm is configured to use the **npm public registry** at
|
||||
<https://registry.npmjs.org> by default.
|
||||
Use of the npm public registry is subject to terms of use available at <https://docs.npmjs.com/policies/terms>.
|
||||
|
||||
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.
|
||||
|
||||
npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.
|
||||
|
||||
The registry URL used is determined by the scope of the package (see [`scope`](/using-npm/scope).
|
||||
If no scope is specified, the default registry is used, which is supplied by the [`registry` config](/using-npm/config#registry) parameter.
|
||||
See [`npm config`](/commands/npm-config), [`npmrc`](/configuring-npm/npmrc), and [`config`](/using-npm/config) for more on managing npm's configuration.
|
||||
Authentication configuration such as auth tokens and certificates are configured specifically scoped to an individual registry.
|
||||
See [Auth Related Configuration](/configuring-npm/npmrc#auth-related-configuration)
|
||||
|
||||
When the default registry is used in a package-lock or shrinkwrap it has the special meaning of "the currently configured registry". If you create a lock file while using the default registry you can switch to another registry and npm will install packages from the new registry, but if you create a lock file while using a custom registry packages will be installed from that registry even after you change to another registry.
|
||||
|
||||
### Does npm send any information about me back to the registry?
|
||||
|
||||
Yes.
|
||||
|
||||
When making requests of the registry npm adds two headers with information about your environment:
|
||||
|
||||
* `Npm-Scope` – 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.
|
||||
* `Npm-In-CI` – 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: `CI`, `TDDIUM`,
|
||||
`JENKINS_URL`, `bamboo.buildKey`.
|
||||
If you'd like to learn more you may find the [original PR](https://github.com/npm/npm-registry-client/pull/129) interesting.
|
||||
This is used to gather better metrics on how npm is used by humans, versus build farms.
|
||||
|
||||
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.
|
||||
|
||||
### How can I prevent my package from being published in the official registry?
|
||||
|
||||
Set `"private": true` in your `package.json` to prevent it from being published at all, or
|
||||
`"publishConfig":{"registry":"http://my-internal-registry.local"}`
|
||||
to force it to be published only to your internal/private registry.
|
||||
|
||||
See [`package.json`](/configuring-npm/package-json) for more info on what goes in the package.json file.
|
||||
|
||||
### Where can I find my (and others') published packages?
|
||||
|
||||
<https://www.npmjs.com/>
|
||||
|
||||
### See also
|
||||
|
||||
* [npm config](/commands/npm-config)
|
||||
* [config](/using-npm/config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm developers](/using-npm/developers)
|
||||
Loaded 100 of 2001 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user