deps: upgrade npm to 11.11.1

PR-URL: https://github.com/nodejs/node/pull/62216
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
npm CLI robot authored and Antoine du Hamel committed 2026-04-10 14:52:21 +02:00
1 parent 84f60c26f7
commit 71a2f82d7c
287 files changed
+2476 -1835

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@ 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.11.0 /path/to/npm
npm@11.11.1 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
```
+1 -1
View File
@@ -7,7 +7,7 @@ description: Manage trusted publishing relationships between packages and CI/CD
### Synopsis
```bash
npm trust
```
Note: This command is unaware of workspaces.
+1 -1
View File
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces.
### Version
11.11.0
11.11.1
### Description
-4
View File
@@ -241,10 +241,6 @@ For more details, see:
- [npm v7 release notes](https://github.com/npm/cli/releases/tag/v7.0.0)
- [Discussion about script working directory reliability in npm v6 and earlier](https://github.com/npm/npm/issues/12356)
### User
When npm is run as root, scripts are always run with the effective uid and gid of the working directory owner.
### Environment
Package scripts run in an environment where many pieces of information are made available regarding the setup of npm and the current state of the process.
+7 -6
View File
@@ -88,24 +88,25 @@ npm install abbrev -w a
**Adding a workspace as a dependency of another workspace:**
If you want to add workspace **b** as a dependency of workspace **a**, you can use the workspace protocol in the dependency specifier:
The same approach works when adding one workspace as a dependency of another.
If you want to add workspace **b** as a dependency of workspace **a**, run:
```
npm install b@workspace:* -w a
npm install b -w a
```
This will add an entry to workspace **a**'s `package.json` like:
npm will detect that **b** is a workspace and automatically symlink it rather
than fetching it from the registry. The resulting entry in workspace **a**'s
`package.json` will use a standard version range:
```json
{
"dependencies": {
"b": "workspace:*"
"b": "^1.0.0"
}
}
```
The `workspace:` protocol tells npm to link to the local workspace rather than fetching from the registry. The `*` version means it will use whatever version is defined in workspace **b**'s `package.json`.
Note: other installing commands such as `uninstall`, `ci`, etc will also respect the provided `workspace` configuration.
### Using workspaces
+1 -1
View File
@@ -94,7 +94,7 @@ const getCommandByDoc = (docFile, docExt, commandLoader = defaultCommandLoader)
name,
workspaces,
definitions: name === 'npx' ? {} : resolvedDefs,
usage: usage.map(u => `${usagePrefix} ${u}`.trim()).join('\n'),
usage: usage?.map(u => `${usagePrefix} ${u}`.trim()).join('\n'),
}
}
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-access----11110">
<h1 id="----npm-access----11111">
<span>npm-access</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Set access level on published packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-adduser----11110">
<h1 id="----npm-adduser----11111">
<span>npm-adduser</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Add a registry user account</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-audit----11110">
<h1 id="----npm-audit----11111">
<span>npm-audit</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Run a security audit</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-bugs----11110">
<h1 id="----npm-bugs----11111">
<span>npm-bugs</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Report bugs for a package in a web browser</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-cache----11110">
<h1 id="----npm-cache----11111">
<span>npm-cache</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manipulates packages cache</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-ci----11110">
<h1 id="----npm-ci----11111">
<span>npm-ci</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Clean install a project</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-completion----11110">
<h1 id="----npm-completion----11111">
<span>npm-completion</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Tab Completion for npm</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-config----11110">
<h1 id="----npm-config----11111">
<span>npm-config</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manage the npm configuration files</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-dedupe----11110">
<h1 id="----npm-dedupe----11111">
<span>npm-dedupe</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Reduce duplication in the package tree</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-deprecate----11110">
<h1 id="----npm-deprecate----11111">
<span>npm-deprecate</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Deprecate a version of a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-diff----11110">
<h1 id="----npm-diff----11111">
<span>npm-diff</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">The registry diff command</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-dist-tag----11110">
<h1 id="----npm-dist-tag----11111">
<span>npm-dist-tag</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Modify package distribution tags</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-docs----11110">
<h1 id="----npm-docs----11111">
<span>npm-docs</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Open documentation for a package in a web browser</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-doctor----11110">
<h1 id="----npm-doctor----11111">
<span>npm-doctor</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Check the health of your npm environment</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-edit----11110">
<h1 id="----npm-edit----11111">
<span>npm-edit</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Edit an installed package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-exec----11110">
<h1 id="----npm-exec----11111">
<span>npm-exec</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Run a command from a local or remote npm package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-explain----11110">
<h1 id="----npm-explain----11111">
<span>npm-explain</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Explain installed packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-explore----11110">
<h1 id="----npm-explore----11111">
<span>npm-explore</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Browse an installed package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-find-dupes----11110">
<h1 id="----npm-find-dupes----11111">
<span>npm-find-dupes</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Find duplication in the package tree</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-fund----11110">
<h1 id="----npm-fund----11111">
<span>npm-fund</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Retrieve funding information</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-get----11110">
<h1 id="----npm-get----11111">
<span>npm-get</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Get a value from the npm configuration</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-help-search----11110">
<h1 id="----npm-help-search----11111">
<span>npm-help-search</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Search npm help documentation</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-help----11110">
<h1 id="----npm-help----11111">
<span>npm-help</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Get help on npm</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-init----11110">
<h1 id="----npm-init----11111">
<span>npm-init</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Create a package.json file</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-install-ci-test----11110">
<h1 id="----npm-install-ci-test----11111">
<span>npm-install-ci-test</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Install a project with a clean slate and run tests</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-install-test----11110">
<h1 id="----npm-install-test----11111">
<span>npm-install-test</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Install package(s) and run tests</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-install----11110">
<h1 id="----npm-install----11111">
<span>npm-install</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Install a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-link----11110">
<h1 id="----npm-link----11111">
<span>npm-link</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Symlink a package folder</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-ll----11110">
<h1 id="----npm-ll----11111">
<span>npm-ll</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">List installed packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-login----11110">
<h1 id="----npm-login----11111">
<span>npm-login</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Login to a registry user account</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-logout----11110">
<h1 id="----npm-logout----11111">
<span>npm-logout</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Log out of the registry</span>
</header>
+3 -3
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-ls----11110">
<h1 id="----npm-ls----11111">
<span>npm-ls</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">List installed packages</span>
</header>
@@ -209,7 +209,7 @@ alias: list
<p>Positional arguments are <code>name@version-range</code> identifiers, which will limit the results to only the paths to the packages named.
Note that nested packages will <em>also</em> show the paths to the specified packages.
For example, running <code>npm ls promzard</code> in npm's source tree will show:</p>
<pre><code class="language-bash">npm@11.11.0 /path/to/npm
<pre><code class="language-bash">npm@11.11.1 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
</code></pre>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-org----11110">
<h1 id="----npm-org----11111">
<span>npm-org</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manage orgs</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-outdated----11110">
<h1 id="----npm-outdated----11111">
<span>npm-outdated</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Check for outdated packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-owner----11110">
<h1 id="----npm-owner----11111">
<span>npm-owner</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manage package owners</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-pack----11110">
<h1 id="----npm-pack----11111">
<span>npm-pack</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Create a tarball from a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-ping----11110">
<h1 id="----npm-ping----11111">
<span>npm-ping</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Ping npm registry</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-pkg----11110">
<h1 id="----npm-pkg----11111">
<span>npm-pkg</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manages your package.json</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-prefix----11110">
<h1 id="----npm-prefix----11111">
<span>npm-prefix</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Display prefix</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-profile----11110">
<h1 id="----npm-profile----11111">
<span>npm-profile</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Change settings on your registry profile</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-prune----11110">
<h1 id="----npm-prune----11111">
<span>npm-prune</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Remove extraneous packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-publish----11110">
<h1 id="----npm-publish----11111">
<span>npm-publish</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Publish a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-query----11110">
<h1 id="----npm-query----11111">
<span>npm-query</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Dependency selector query</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-rebuild----11110">
<h1 id="----npm-rebuild----11111">
<span>npm-rebuild</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Rebuild a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-repo----11110">
<h1 id="----npm-repo----11111">
<span>npm-repo</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Open package repository page in the browser</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-restart----11110">
<h1 id="----npm-restart----11111">
<span>npm-restart</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Restart a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-root----11110">
<h1 id="----npm-root----11111">
<span>npm-root</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Display npm root</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-run----11110">
<h1 id="----npm-run----11111">
<span>npm-run</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Run arbitrary package scripts</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-sbom----11110">
<h1 id="----npm-sbom----11111">
<span>npm-sbom</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Generate a Software Bill of Materials (SBOM)</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-search----11110">
<h1 id="----npm-search----11111">
<span>npm-search</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Search for packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-set----11110">
<h1 id="----npm-set----11111">
<span>npm-set</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Set a value in the npm configuration</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-shrinkwrap----11110">
<h1 id="----npm-shrinkwrap----11111">
<span>npm-shrinkwrap</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Lock down dependency versions for publication</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-star----11110">
<h1 id="----npm-star----11111">
<span>npm-star</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Mark your favorite packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-stars----11110">
<h1 id="----npm-stars----11111">
<span>npm-stars</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">View packages marked as favorites</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-start----11110">
<h1 id="----npm-start----11111">
<span>npm-start</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Start a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-stop----11110">
<h1 id="----npm-stop----11111">
<span>npm-stop</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Stop a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-team----11110">
<h1 id="----npm-team----11111">
<span>npm-team</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manage organization teams and team memberships</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-test----11110">
<h1 id="----npm-test----11111">
<span>npm-test</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Test a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-token----11110">
<h1 id="----npm-token----11111">
<span>npm-token</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manage your authentication tokens</span>
</header>
+3 -4
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-trust----11110">
<h1 id="----npm-trust----11111">
<span>npm-trust</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Manage trusted publishing relationships between packages and CI/CD providers</span>
</header>
@@ -199,8 +199,7 @@ npm command-line interface
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
<pre><code class="language-bash">npm trust
</code></pre>
<pre><code class="language-bash"></code></pre>
<p>Note: This command is unaware of workspaces.</p>
<h3 id="prerequisites">Prerequisites</h3>
<p>Before using npm trust commands, ensure the following requirements are met:</p>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-undeprecate----11110">
<h1 id="----npm-undeprecate----11111">
<span>npm-undeprecate</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Undeprecate a version of a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-uninstall----11110">
<h1 id="----npm-uninstall----11111">
<span>npm-uninstall</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Remove a package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-unpublish----11110">
<h1 id="----npm-unpublish----11111">
<span>npm-unpublish</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Remove a package from the registry</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-unstar----11110">
<h1 id="----npm-unstar----11111">
<span>npm-unstar</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Remove an item from your favorite packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-update----11110">
<h1 id="----npm-update----11111">
<span>npm-update</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Update packages</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-version----11110">
<h1 id="----npm-version----11111">
<span>npm-version</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Bump a package version</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-view----11110">
<h1 id="----npm-view----11111">
<span>npm-view</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">View registry info</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-whoami----11110">
<h1 id="----npm-whoami----11111">
<span>npm-whoami</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Display npm username</span>
</header>
+3 -3
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm----11110">
<h1 id="----npm----11111">
<span>npm</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">javascript package manager</span>
</header>
@@ -203,7 +203,7 @@ npm command-line interface
</code></pre>
<p>Note: This command is unaware of workspaces.</p>
<h3 id="version">Version</h3>
<p>11.11.0</p>
<p>11.11.1</p>
<h3 id="description">Description</h3>
<p>npm is the package manager for the Node JavaScript platform.
It puts modules in place so that node can find them, and manages dependency conflicts intelligently.</p>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npx----11110">
<h1 id="----npx----11111">
<span>npx</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Run a command from a local or remote npm package</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----folders----11110">
<h1 id="----folders----11111">
<span>Folders</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Folder structures used by npm</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----install----11110">
<h1 id="----install----11111">
<span>Install</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Download and install node and npm</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----folders----11110">
<h1 id="----folders----11111">
<span>Folders</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Folder structures used by npm</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----packagejson----11110">
<h1 id="----packagejson----11111">
<span>package.json</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Specifics of npm's package.json handling</span>
</header>
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npm-shrinkwrapjson----11110">
<h1 id="----npm-shrinkwrapjson----11111">
<span>npm-shrinkwrap.json</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">A publishable lockfile</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----npmrc----11110">
<h1 id="----npmrc----11111">
<span>.npmrc</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">The npm config files</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----packagejson----11110">
<h1 id="----packagejson----11111">
<span>package.json</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Specifics of npm's package.json handling</span>
</header>
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----package-lockjson----11110">
<h1 id="----package-lockjson----11111">
<span>package-lock.json</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">A manifestation of the manifest</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----config----11110">
<h1 id="----config----11111">
<span>Config</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">About npm configuration</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----dependency-selectors----11110">
<h1 id="----dependency-selectors----11111">
<span>Dependency Selectors</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Dependency Selector Syntax &amp; Querying</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----developers----11110">
<h1 id="----developers----11111">
<span>Developers</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Developer guide</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----logging----11110">
<h1 id="----logging----11111">
<span>Logging</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Why, What &amp; How we Log</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----organizations----11110">
<h1 id="----organizations----11111">
<span>Organizations</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Working with teams &amp; organizations</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----package-spec----11110">
<h1 id="----package-spec----11111">
<span>Package spec</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Package name specifier</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----registry----11110">
<h1 id="----registry----11111">
<span>Registry</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">The JavaScript Package Registry</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----removal----11110">
<h1 id="----removal----11111">
<span>Removal</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Cleaning the slate</span>
</header>
+2 -2
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----scope----11110">
<h1 id="----scope----11111">
<span>Scope</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Scoped packages</span>
</header>
+3 -5
View File
@@ -186,16 +186,16 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----scripts----11110">
<h1 id="----scripts----11111">
<span>Scripts</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">How npm handles the "scripts" field</span>
</header>
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><li><a href="#pre--post-scripts">Pre &amp; Post Scripts</a></li><li><a href="#life-cycle-scripts">Life Cycle Scripts</a></li><ul><li><a href="#prepare-and-prepublish">Prepare and Prepublish</a></li><li><a href="#dependencies">Dependencies</a></li></ul><li><a href="#life-cycle-operation-order">Life Cycle Operation Order</a></li><ul><li><a href="#npm-cache-add"><a href="../commands/npm-cache.html"><code>npm cache add</code></a></a></li><li><a href="#npm-ci"><a href="../commands/npm-ci.html"><code>npm ci</code></a></a></li><li><a href="#npm-diff"><a href="../commands/npm-diff.html"><code>npm diff</code></a></a></li><li><a href="#npm-install"><a href="../commands/npm-install.html"><code>npm install</code></a></a></li><li><a href="#npm-pack"><a href="../commands/npm-pack.html"><code>npm pack</code></a></a></li><li><a href="#npm-publish"><a href="../commands/npm-publish.html"><code>npm publish</code></a></a></li><li><a href="#npm-rebuild"><a href="../commands/npm-rebuild.html"><code>npm rebuild</code></a></a></li><li><a href="#npm-restart"><a href="../commands/npm-restart.html"><code>npm restart</code></a></a></li><li><a href="#npm-run-user-defined"><a href="../commands/npm-run.html"><code>npm run &lt;user defined&gt;</code></a></a></li><li><a href="#npm-start"><a href="../commands/npm-start.html"><code>npm start</code></a></a></li><li><a href="#npm-stop"><a href="../commands/npm-stop.html"><code>npm stop</code></a></a></li><li><a href="#npm-test"><a href="../commands/npm-test.html"><code>npm test</code></a></a></li><li><a href="#npm-version"><a href="../commands/npm-version.html"><code>npm version</code></a></a></li><li><a href="#a-note-on-a-lack-of-npm-uninstall-scripts">A Note on a lack of <a href="../commands/npm-uninstall.html"><code>npm uninstall</code></a> scripts</a></li></ul><li><a href="#working-directory-for-scripts">Working Directory for Scripts</a></li><ul><li><a href="#historical-behavior-in-older-npm-versions">Historical Behavior in Older npm Versions</a></li></ul><li><a href="#user">User</a></li><li><a href="#environment">Environment</a></li><ul><li><a href="#path">path</a></li><li><a href="#packagejson-vars">package.json vars</a></li><li><a href="#current-lifecycle-event">current lifecycle event</a></li></ul><li><a href="#examples">Examples</a></li><li><a href="#exiting">Exiting</a></li><li><a href="#best-practices">Best Practices</a></li><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><li><a href="#pre--post-scripts">Pre &amp; Post Scripts</a></li><li><a href="#life-cycle-scripts">Life Cycle Scripts</a></li><ul><li><a href="#prepare-and-prepublish">Prepare and Prepublish</a></li><li><a href="#dependencies">Dependencies</a></li></ul><li><a href="#life-cycle-operation-order">Life Cycle Operation Order</a></li><ul><li><a href="#npm-cache-add"><a href="../commands/npm-cache.html"><code>npm cache add</code></a></a></li><li><a href="#npm-ci"><a href="../commands/npm-ci.html"><code>npm ci</code></a></a></li><li><a href="#npm-diff"><a href="../commands/npm-diff.html"><code>npm diff</code></a></a></li><li><a href="#npm-install"><a href="../commands/npm-install.html"><code>npm install</code></a></a></li><li><a href="#npm-pack"><a href="../commands/npm-pack.html"><code>npm pack</code></a></a></li><li><a href="#npm-publish"><a href="../commands/npm-publish.html"><code>npm publish</code></a></a></li><li><a href="#npm-rebuild"><a href="../commands/npm-rebuild.html"><code>npm rebuild</code></a></a></li><li><a href="#npm-restart"><a href="../commands/npm-restart.html"><code>npm restart</code></a></a></li><li><a href="#npm-run-user-defined"><a href="../commands/npm-run.html"><code>npm run &lt;user defined&gt;</code></a></a></li><li><a href="#npm-start"><a href="../commands/npm-start.html"><code>npm start</code></a></a></li><li><a href="#npm-stop"><a href="../commands/npm-stop.html"><code>npm stop</code></a></a></li><li><a href="#npm-test"><a href="../commands/npm-test.html"><code>npm test</code></a></a></li><li><a href="#npm-version"><a href="../commands/npm-version.html"><code>npm version</code></a></a></li><li><a href="#a-note-on-a-lack-of-npm-uninstall-scripts">A Note on a lack of <a href="../commands/npm-uninstall.html"><code>npm uninstall</code></a> scripts</a></li></ul><li><a href="#working-directory-for-scripts">Working Directory for Scripts</a></li><ul><li><a href="#historical-behavior-in-older-npm-versions">Historical Behavior in Older npm Versions</a></li></ul><li><a href="#environment">Environment</a></li><ul><li><a href="#path">path</a></li><li><a href="#packagejson-vars">package.json vars</a></li><li><a href="#current-lifecycle-event">current lifecycle event</a></li></ul><li><a href="#examples">Examples</a></li><li><a href="#exiting">Exiting</a></li><li><a href="#best-practices">Best Practices</a></li><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="description">Description</h3>
@@ -421,8 +421,6 @@ If your package must support very old npm versions, you may wish to add a safegu
<li><a href="https://github.com/npm/cli/releases/tag/v7.0.0">npm v7 release notes</a></li>
<li><a href="https://github.com/npm/npm/issues/12356">Discussion about script working directory reliability in npm v6 and earlier</a></li>
</ul>
<h3 id="user">User</h3>
<p>When npm is run as root, scripts are always run with the effective uid and gid of the working directory owner.</p>
<h3 id="environment">Environment</h3>
<p>Package scripts run in an environment where many pieces of information are made available regarding the setup of npm and the current state of the process.</p>
<h4 id="path">path</h4>
+9 -7
View File
@@ -186,9 +186,9 @@ npm command-line interface
<section id="content">
<header class="title">
<h1 id="----workspaces----11110">
<h1 id="----workspaces----11111">
<span>Workspaces</span>
<span class="version">@11.11.0</span>
<span class="version">@11.11.1</span>
</h1>
<span class="description">Working with workspaces</span>
</header>
@@ -253,17 +253,19 @@ For example in a project that already has a <code>package.json</code> defined yo
<pre><code>npm install abbrev -w a
</code></pre>
<p><strong>Adding a workspace as a dependency of another workspace:</strong></p>
<p>If you want to add workspace <strong>b</strong> as a dependency of workspace <strong>a</strong>, you can use the workspace protocol in the dependency specifier:</p>
<pre><code>npm install b@workspace:* -w a
<p>The same approach works when adding one workspace as a dependency of another.
If you want to add workspace <strong>b</strong> as a dependency of workspace <strong>a</strong>, run:</p>
<pre><code>npm install b -w a
</code></pre>
<p>This will add an entry to workspace <strong>a</strong>'s <code>package.json</code> like:</p>
<p>npm will detect that <strong>b</strong> is a workspace and automatically symlink it rather
than fetching it from the registry. The resulting entry in workspace <strong>a</strong>'s
<code>package.json</code> will use a standard version range:</p>
<pre><code class="language-json">{
"dependencies": {
"b": "workspace:*"
"b": "^1.0.0"
}
}
</code></pre>
<p>The <code>workspace:</code> protocol tells npm to link to the local workspace rather than fetching from the registry. The <code>*</code> version means it will use whatever version is defined in workspace <strong>b</strong>'s <code>package.json</code>.</p>
<p>Note: other installing commands such as <code>uninstall</code>, <code>ci</code>, etc will also respect the provided <code>workspace</code> configuration.</p>
<h3 id="using-workspaces">Using workspaces</h3>
<p>Given the <a href="https://nodejs.org/dist/latest-v14.x/docs/api/modules.html#modules_all_together">specifics of how Node.js handles module resolution</a> it's possible to consume any defined workspace by its declared <code>package.json</code> <code>name</code>.
+3 -7
View File
@@ -1,9 +1,7 @@
const { log } = require('proc-log')
const BaseCommand = require('./base-cmd.js')
// This is the base for all commands whose execWorkspaces just gets
// a list of workspace names and passes it on to new Arborist() to
// be able to run a filtered Arborist.reify() at some point.
// This is the base for all commands whose execWorkspaces just gets a list of workspace names and passes it on to new Arborist() to be able to run a filtered Arborist.reify() at some point.
class ArboristCmd extends BaseCommand {
get isArboristCmd () {
return true
@@ -25,8 +23,7 @@ class ArboristCmd extends BaseCommand {
const { config } = this.npm
// when location isn't set and global isn't true check for a package.json at
// the localPrefix and set the location to project if found
// when location isn't set and global isn't true check for a package.json at the localPrefix and set the location to project if found
const locationProject = config.get('location') === 'project' || (
config.isDefault('location')
// this is different then `npm.global` which falls back to checking
@@ -35,8 +32,7 @@ class ArboristCmd extends BaseCommand {
&& npm.localPackage
)
// if audit is not set and we are in global mode and location is not project
// and we assume its not a project related context, then we set audit=false
// if audit is not set and we are in global mode and location is not project and we assume its not a project related context, then we set audit=false
if (config.isDefault('audit') && (this.npm.global || !locationProject)) {
config.set('audit', false)
} else if (this.npm.global && config.get('audit')) {
+10 -9
View File
@@ -17,8 +17,7 @@ class BaseCommand {
// Number of expected positional arguments (null = unlimited/unchecked)
static positionals = null
// this is a static so that we can read from it without instantiating a command
// which would require loading the config
// this is a static so that we can read from it without instantiating a command which would require loading the config
static get describeUsage () {
return this.getUsage()
}
@@ -29,8 +28,7 @@ class BaseCommand {
const wrapWidth = 80
const { description, usage = [''], name } = this
// Resolve to a definitions array: if the command has its own definitions, use
// those directly; otherwise resolve params from the global definitions pool.
// Resolve to a definitions array: if the command has its own definitions, use those directly; otherwise resolve params from the global definitions pool.
let cmdDefs
if (this.definitions) {
cmdDefs = this.definitions
@@ -45,10 +43,15 @@ class BaseCommand {
`${description}`,
'',
'Usage:',
...usage.map(u => `npm ${fullCommandName} ${u}`.trim()),
]
if (usage) {
fullUsage.push(...usage.map(u => `npm ${fullCommandName} ${u}`.trim()))
}
if (this.subcommands) {
for (const sub in this.subcommands) {
fullUsage.push(`npm ${fullCommandName} ${sub} ${this.subcommands[sub].usage}`)
}
fullUsage.push('')
fullUsage.push('Subcommands:')
const subcommandEntries = Object.entries(this.subcommands)
@@ -392,8 +395,7 @@ class BaseCommand {
throw this.usageError(`Unknown flag${unknownFlags.length > 1 ? 's' : ''}: ${flagList}`)
}
// Remove warnings for command-specific definitions that npm's global config
// doesn't know about (these were queued as "unknown" during config.load())
// Remove warnings for command-specific definitions that npm's global config doesn't know about (these were queued as "unknown" during config.load())
for (const def of commandDefinitions) {
this.npm.config.removeWarning(def.key)
if (def.alias && Array.isArray(def.alias)) {
@@ -403,8 +405,7 @@ class BaseCommand {
}
}
// Remove warnings for unknown positionals that were actually consumed as flag values
// by command-specific definitions (e.g., --id <value> where --id is command-specific)
// Remove warnings for unknown positionals that were actually consumed as flag values by command-specific definitions (e.g., --id <value> where --id is command-specific)
const remainsSet = new Set(remains)
for (const unknownPos of this.npm.config.getUnknownPositionals()) {
if (!remainsSet.has(unknownPos)) {
+7 -7
View File
@@ -1,7 +1,6 @@
// Separated out for easier unit testing
module.exports = async (process, validateEngines) => {
// set it here so that regardless of what happens later, we don't
// leak any private CLI configs to other programs
// set it here so that regardless of what happens later, we don't leak any private CLI configs to other programs
process.title = 'npm'
// Patch the global fs module here at the app level
@@ -20,11 +19,13 @@ module.exports = async (process, validateEngines) => {
log.info('using', 'npm@%s', npm.version)
log.info('using', 'node@%s', process.version)
// At this point we've required a few files and can be pretty sure we don't contain invalid syntax for this version of node. It's possible a lazy require would, but that's unlikely enough that it's not worth catching anymore and we attach the more important exit handlers.
// At this point we've required a few files and can be pretty sure we don't contain invalid syntax for this version of node.
// It's possible a lazy require would, but that's unlikely enough that it's not worth catching anymore and we attach the more important exit handlers.
validateEngines.off()
exitHandler.registerUncaughtHandlers()
// It is now safe to log a warning if they are using a version of node that is not going to fail on syntax errors but is still unsupported and untested and might not work reliably. This is safe to use the logger now which we want since this will show up in the error log too.
// It is now safe to log a warning if they are using a version of node that is not going to fail on syntax errors but is still unsupported and untested and might not work reliably.
// This is safe to use the logger now which we want since this will show up in the error log too.
if (!satisfies(validateEngines.node, validateEngines.engines)) {
log.warn('cli', validateEngines.unsupportedMessage)
}
@@ -57,9 +58,8 @@ module.exports = async (process, validateEngines) => {
const execPromise = npm.exec(command, args)
// this is async but we don't await it, since its ok if it doesnt
// finish before the command finishes running. it uses command and argv
// so it must be initiated here, after the command name is set
// this is async but we don't await it, since its ok if it doesnt finish before the command finishes running.
// it uses command and argv so it must be initiated here, after the command name is set
const updateNotifier = require('./update-notifier.js')
// eslint-disable-next-line promise/catch-or-return
updateNotifier(npm).then((msg) => (npm.updateNotification = msg))
+8 -14
View File
@@ -52,8 +52,7 @@ class ExitHandler {
#handleProcessExitAndReset = (code) => {
this.#handleProcessExit(code)
// Reset all the state. This is only relevant for tests since
// in reality the process fully exits here.
// Reset all the state. This is only relevant for tests since in reality the process fully exits here.
this.#process.off('exit', this.#handleProcessExitAndReset)
this.#process.off('uncaughtException', this.#handleExit)
this.#process.off('unhandledRejection', this.#handleExit)
@@ -115,9 +114,8 @@ class ExitHandler {
}
#logConsoleError (err) {
// Run our error message formatters on all errors even if we
// have no npm or an unloaded npm. This will clean the error
// and possible return a formatted message about EACCESS or something.
// Run our error message formatters on all errors even if we have no npm or an unloaded npm.
// This will clean the error and possible return a formatted message about EACCESS or something.
const { summary, detail } = errorMessage(err, this.#npm)
const formatted = [...new Set([...summary, ...detail].flat().filter(Boolean))].join('\n')
// If we didn't get anything from the formatted message then just display the full stack
@@ -147,9 +145,7 @@ class ExitHandler {
return this.#process.exit(this.#process.exitCode || getExitCodeFromError(err) || 1)
}
// npm was never loaded but we still might have a config loading error or
// something similar that we can run through the error message formatter
// to give the user a clue as to what happened.s
// npm was never loaded but we still might have a config loading error or something similar that we can run through the error message formatter to give the user a clue as to what happened.
if (!this.#loaded) {
this.#logConsoleError(new Error('Exit prior to config file resolving', { cause: err }))
return this.#process.exit(this.#process.exitCode || getExitCodeFromError(err) || 1)
@@ -157,14 +153,12 @@ class ExitHandler {
this.#exitErrorMessage = err?.suppressError === true ? false : !!err
// Prefer the exit code of the error, then the current process exit code,
// then set it to 1 if we still have an error. Otherwise, we call process.exit
// with undefined so that it can determine the final exit code
// Prefer the exit code of the error, then the current process exit code, then set it to 1 if we still have an error.
// Otherwise, we call process.exit with undefined so that it can determine the final exit code
const exitCode = err?.exitCode ?? this.#process.exitCode ?? (err ? 1 : undefined)
// explicitly call process.exit now so we don't hang on things like the
// update notifier, also flush stdout/err beforehand because process.exit doesn't
// wait for that to happen.
// explicitly call process.exit now so we don't hang on things like the update notifier
// also flush stdout/err beforehand because process.exit doesn't wait for that to happen.
this.#process.stderr.write('', () => this.#process.stdout.write('', () => {
this.#process.exit(exitCode)
}))
+21 -26
View File
@@ -1,6 +1,4 @@
// print a banner telling the user to upgrade npm to latest
// but not in CI, and not if we're doing that already.
// Check daily for betas, and weekly otherwise.
// print a banner telling the user to upgrade npm to latest but not in CI, and not if we're doing that already.
const ciInfo = require('ci-info')
const gt = require('semver/functions/gt')
@@ -14,11 +12,9 @@ const DAILY = 1000 * 60 * 60 * 24
const WEEKLY = DAILY * 7
// don't put it in the _cacache folder, just in npm's cache
const lastCheckedFile = npm =>
resolve(npm.flatOptions.cache, '../_update-notifier-last-checked')
const lastCheckedFile = npm => resolve(npm.flatOptions.cache, '../_update-notifier-last-checked')
// Actual check for updates. This is a separate function so that we only load
// this if we are doing the actual update
// Actual check for updates. This is a separate function so that we only load this if we are doing the actual update
const updateCheck = async (npm, spec, version, current) => {
const pacote = require('pacote')
@@ -36,10 +32,8 @@ const updateCheck = async (npm, spec, version, current) => {
const latest = mani.version
// if the current version is *greater* than latest, we're on a 'next'
// and should get the updates from that release train.
// Note that this isn't another http request over the network, because
// the packument will be cached by pacote from previous request.
// if the current version is *greater* than latest, we're on a 'next' and should get the updates from that release train.
// Note that this isn't another http request over the network, because the packument will be cached by pacote from previous request.
if (gt(version, latest) && spec === '*') {
return updateNotifier(npm, `^${version}`)
}
@@ -51,9 +45,8 @@ const updateCheck = async (npm, spec, version, current) => {
const chalk = npm.logChalk
// ok! notify the user about this update they should get.
// The message is saved for printing at process exit so it will not get
// lost in any other messages being printed as part of the command.
// ok! notify the user about this update they should get.
// The message is saved for printing at process exit so it will not get lost in any other messages being printed as part of the command.
const update = parse(mani.version)
const type = update.major !== current.major ? 'major'
: update.minor !== current.minor ? 'minor'
@@ -62,18 +55,20 @@ const updateCheck = async (npm, spec, version, current) => {
const typec = type === 'major' ? 'red'
: type === 'minor' ? 'yellow'
: 'cyan'
const cmd = `npm install -g npm@${latest}`
const message = `\nNew ${chalk[typec](type)} version of npm available! ` +
`${chalk[typec](current)} -> ${chalk.blue(latest)}\n` +
`Changelog: ${chalk.blue(`https://github.com/npm/cli/releases/tag/v${latest}`)}\n` +
`To update run: ${chalk.underline(cmd)}\n`
const message = [
'',
`New ${chalk[typec](type)} version of npm available! ${chalk[typec](current)} -> ${chalk.blue(latest)}`,
`Changelog: ${chalk.blue(`https://github.com/npm/cli/releases/tag/v${latest}`)}`,
`To update run: ${chalk.underline(`npm install -g npm@${latest}`)}`,
'',
].join('\n')
return message
}
const updateNotifier = async (npm, spec = '*') => {
// if we're on a prerelease train, then updates are coming fast
// check for a new one daily. otherwise, weekly.
// if we're on a prerelease train, then updates are coming fast check for a new one daily.
// otherwise, weekly.
const { version } = npm
const current = parse(version)
@@ -94,15 +89,15 @@ const updateNotifier = async (npm, spec = '*') => {
return null
}
// intentional. do not await this. it's a best-effort update. if this
// fails, it's ok. might be using /dev/null as the cache or something weird
// like that.
// intentional. do not await this. it's a best-effort update.
// if this fails, it's ok.
// might be using /dev/null as the cache or something weird like that.
writeFile(lastCheckedFile(npm), '').catch(() => {})
return updateCheck(npm, spec, version, current)
}
module.exports = npm => {
module.exports = async npm => {
if (
// opted out
!npm.config.get('update-notifier')
@@ -113,7 +108,7 @@ module.exports = npm => {
// CI
|| ciInfo.isCI
) {
return Promise.resolve(null)
return null
}
return updateNotifier(npm)
Loaded 100 of 287 files, more files were not shown because too many files have changed in this diff. Show more