deps: upgrade npm to 9.7.1

PR-URL: https://github.com/nodejs/node/pull/48378
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Luke Karrys <luke@lukekarrys.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
npm CLI robot authored and RafaelGSS committed 2023-07-03 10:32:47 -03:00
1 parent 7c790ca03c
commit b339d80a56
321 files changed
+4636 -3441

No files matched your search

+6
View File
@@ -90,6 +90,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `otp`
* Default: null
@@ -101,6 +103,8 @@ 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/"
@@ -108,6 +112,8 @@ password, npm will prompt on the command line for one.
The base URL of the npm registry.
### See Also
* [`libnpmaccess`](https://npm.im/libnpmaccess)
+5
View File
@@ -32,6 +32,8 @@ email are read in from prompts.
The base URL of the npm registry.
#### `scope`
* Default: the scope of the current project, if any, or ""
@@ -62,6 +64,7 @@ npm init --scope=@foo --yes
```
#### `auth-type`
* Default: "web"
@@ -70,6 +73,8 @@ npm init --scope=@foo --yes
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)
+18
View File
@@ -246,6 +246,8 @@ $ npm audit --audit-level=moderate
The minimum level of vulnerability for `npm audit` to exit with a non-zero
exit code.
#### `dry-run`
* Default: false
@@ -259,6 +261,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `force`
* Default: false
@@ -285,6 +289,8 @@ mistakes, unnecessary performance degradation, and malicious input.
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
@@ -297,6 +303,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `package-lock-only`
* Default: false
@@ -311,6 +319,8 @@ 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`.
#### `omit`
* Default: 'dev' if the `NODE_ENV` environment variable is set to
@@ -329,6 +339,8 @@ 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.
#### `foreground-scripts`
* Default: false
@@ -341,6 +353,8 @@ 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
@@ -353,6 +367,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `workspace`
* Default:
@@ -415,6 +431,8 @@ 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)
+4
View File
@@ -34,6 +34,8 @@ terminal.
Set to `true` to use default system URL opener.
#### `registry`
* Default: "https://registry.npmjs.org/"
@@ -41,6 +43,8 @@ Set to `true` to use default system URL opener.
The base URL of the npm registry.
#### `workspace`
* Default:
+2
View File
@@ -77,6 +77,8 @@ verify`.
The location of npm's cache directory.
### See Also
* [package spec](/using-npm/package-spec)
+22 -8
View File
@@ -84,6 +84,8 @@ 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
@@ -96,6 +98,8 @@ 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
@@ -106,6 +110,8 @@ de-duplicating. Sets `--install-strategy=nested`.
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
@@ -124,6 +130,8 @@ 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.
#### `strict-peer-deps`
* Default: false
@@ -143,15 +151,7 @@ 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.
This configuration does not affect `npm ci`.
#### `foreground-scripts`
@@ -165,6 +165,8 @@ 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
@@ -177,6 +179,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -187,6 +191,8 @@ 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
@@ -199,6 +205,8 @@ 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
@@ -208,6 +216,8 @@ 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
@@ -221,6 +231,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `workspace`
* Default:
@@ -283,6 +295,8 @@ 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)
+10
View File
@@ -116,6 +116,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `global`
* Default: false
@@ -130,6 +132,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `editor`
* Default: The EDITOR or VISUAL environment variables, or
@@ -138,6 +142,8 @@ folder instead of the current working directory. See
The command to run for `npm edit` and `npm config edit`.
#### `location`
* Default: "user" unless `--global` is passed, which will also set this value
@@ -155,6 +161,8 @@ instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `long`
* Default: false
@@ -162,6 +170,8 @@ instead of the current working directory. See
Show extended information in `ls`, `search`, and `help-search`.
### See Also
* [npm folders](/configuring-npm/folders)
+23 -1
View File
@@ -89,6 +89,8 @@ 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
@@ -101,6 +103,8 @@ 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
@@ -111,6 +115,8 @@ de-duplicating. Sets `--install-strategy=nested`.
Only install direct dependencies in the top level `node_modules`, but hoist
on deeper dependencies. Sets `--install-strategy=shallow`.
#### `strict-peer-deps`
* Default: false
@@ -130,6 +136,8 @@ 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
@@ -138,7 +146,7 @@ this warning is treated as a failure.
If set to false, then ignore `package-lock.json` files when installing. This
will also prevent _writing_ `package-lock.json` if `save` is true.
This configuration does not affect `npm ci`.
#### `omit`
@@ -158,6 +166,8 @@ 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.
#### `ignore-scripts`
* Default: false
@@ -170,6 +180,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -180,6 +192,8 @@ 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
@@ -192,6 +206,8 @@ 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
@@ -201,6 +217,8 @@ 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
@@ -214,6 +232,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `workspace`
* Default:
@@ -276,6 +296,8 @@ 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)
+4
View File
@@ -49,6 +49,8 @@ format an empty string.
The base URL of the npm registry.
#### `otp`
* Default: null
@@ -60,6 +62,8 @@ 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)
+20
View File
@@ -156,6 +156,8 @@ located within the folder `./lib/` and changed lines of code within the
Define arguments to compare in `npm diff`.
#### `diff-name-only`
* Default: false
@@ -163,6 +165,8 @@ Define arguments to compare in `npm diff`.
Prints only filenames when using `npm diff`.
#### `diff-unified`
* Default: 3
@@ -170,6 +174,8 @@ Prints only filenames when using `npm diff`.
The number of lines of context to print in `npm diff`.
#### `diff-ignore-all-space`
* Default: false
@@ -177,6 +183,8 @@ The number of lines of context to print in `npm diff`.
Ignore whitespace when comparing lines in `npm diff`.
#### `diff-no-prefix`
* Default: false
@@ -187,6 +195,8 @@ 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/"
@@ -194,6 +204,8 @@ Note: this causes `npm diff` to ignore the `--diff-src-prefix` and
Source prefix to be used in `npm diff` output.
#### `diff-dst-prefix`
* Default: "b/"
@@ -201,6 +213,8 @@ Source prefix to be used in `npm diff` output.
Destination prefix to be used in `npm diff` output.
#### `diff-text`
* Default: false
@@ -208,6 +222,8 @@ Destination prefix to be used in `npm diff` output.
Treat all files as text in `npm diff`.
#### `global`
* Default: false
@@ -222,6 +238,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `tag`
* Default: "latest"
@@ -236,6 +254,8 @@ 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.
#### `workspace`
* Default:
+4
View File
@@ -34,6 +34,8 @@ terminal.
Set to `true` to use default system URL opener.
#### `registry`
* Default: "https://registry.npmjs.org/"
@@ -41,6 +43,8 @@ Set to `true` to use default system URL opener.
The base URL of the npm registry.
#### `workspace`
* Default:
+2
View File
@@ -113,6 +113,8 @@ reset the cache.
The base URL of the npm registry.
### See Also
* [npm bugs](/commands/npm-bugs)
+2
View File
@@ -35,6 +35,8 @@ changes to your locally installed copy.
The command to run for `npm edit` and `npm config edit`.
### See Also
* [npm folders](/configuring-npm/folders)
+3
View File
@@ -118,6 +118,8 @@ $ npm exec -- foo@latest bar --package=@npmcli/foo
The package or packages to install for [`npm exec`](/commands/npm-exec)
#### `call`
* Default: ""
@@ -131,6 +133,7 @@ npm exec --package yo --package generator-node --call "yo node"
```
#### `workspace`
* Default:
+2
View File
@@ -67,6 +67,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `workspace`
* Default:
+2
View File
@@ -39,6 +39,8 @@ sure to use `npm rebuild <pkg>` if you make any changes.
The shell to run for the `npm explore` command.
### See Also
* [npm folders](/configuring-npm/folders)
+21 -1
View File
@@ -29,6 +29,8 @@ 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
@@ -41,6 +43,8 @@ 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
@@ -51,6 +55,8 @@ de-duplicating. Sets `--install-strategy=nested`.
Only install direct dependencies in the top level `node_modules`, but hoist
on deeper dependencies. Sets `--install-strategy=shallow`.
#### `strict-peer-deps`
* Default: false
@@ -70,6 +76,8 @@ 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
@@ -78,7 +86,7 @@ this warning is treated as a failure.
If set to false, then ignore `package-lock.json` files when installing. This
will also prevent _writing_ `package-lock.json` if `save` is true.
This configuration does not affect `npm ci`.
#### `omit`
@@ -98,6 +106,8 @@ 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.
#### `ignore-scripts`
* Default: false
@@ -110,6 +120,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -120,6 +132,8 @@ 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
@@ -132,6 +146,8 @@ 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
@@ -141,6 +157,8 @@ 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:
@@ -203,6 +221,8 @@ 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)
+8
View File
@@ -77,6 +77,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `browser`
* Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
@@ -89,6 +91,8 @@ terminal.
Set to `true` to use default system URL opener.
#### `unicode`
* Default: false on windows, true on mac/unix systems with a unicode locale,
@@ -98,6 +102,8 @@ Set to `true` to use default system URL opener.
When set to true, npm uses unicode characters in the tree output. When
false, it uses ascii characters instead of unicode glyphs.
#### `workspace`
* Default:
@@ -127,6 +133,8 @@ This value is not exported to the environment for child processes.
If there are multiple funding sources, which 1-indexed source URL to open.
## See Also
* [package spec](/using-npm/package-spec)
+2
View File
@@ -32,6 +32,8 @@ directly.
Show extended information in `ls`, `search`, and `help-search`.
### See Also
* [npm](/commands/npm)
+2
View File
@@ -34,6 +34,8 @@ 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)
+4
View File
@@ -92,6 +92,8 @@ $ npm hook rm id-deadbeef
The base URL of the npm registry.
#### `otp`
* Default: null
@@ -103,6 +105,8 @@ 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
* ["Introducing Hooks" blog post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm)
+7
View File
@@ -164,6 +164,8 @@ dot to represent the current directory in that context, e.g: `react-app .`:
Automatically answer "yes" to any prompts that npm might print on the
command line.
#### `force`
* Default: false
@@ -190,6 +192,8 @@ mistakes, unnecessary performance degradation, and malicious input.
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 ""
@@ -220,6 +224,7 @@ npm init --scope=@foo --yes
```
#### `workspace`
* Default:
@@ -268,6 +273,8 @@ This value is not exported to the environment for child processes.
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
+22 -8
View File
@@ -30,6 +30,8 @@ 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
@@ -42,6 +44,8 @@ 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
@@ -52,6 +56,8 @@ de-duplicating. Sets `--install-strategy=nested`.
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
@@ -70,6 +76,8 @@ 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.
#### `strict-peer-deps`
* Default: false
@@ -89,15 +97,7 @@ 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.
This configuration does not affect `npm ci`.
#### `foreground-scripts`
@@ -111,6 +111,8 @@ 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
@@ -123,6 +125,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -133,6 +137,8 @@ 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
@@ -145,6 +151,8 @@ 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
@@ -154,6 +162,8 @@ 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
@@ -167,6 +177,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `workspace`
* Default:
@@ -229,6 +241,8 @@ 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)
+41 -1
View File
@@ -31,6 +31,8 @@ When used with the `npm rm` command, removes the dependency from
Will also prevent writing to `package-lock.json` if set to `false`.
#### `save-exact`
* Default: false
@@ -39,6 +41,8 @@ Will also prevent writing to `package-lock.json` if set to `false`.
Dependencies saved to package.json will be configured with an exact version
rather than using npm's default semver range operator.
#### `global`
* Default: false
@@ -53,6 +57,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `install-strategy`
* Default: "hoisted"
@@ -65,6 +71,8 @@ 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
@@ -77,6 +85,8 @@ 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
@@ -87,6 +97,8 @@ de-duplicating. Sets `--install-strategy=nested`.
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
@@ -105,6 +117,8 @@ 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.
#### `strict-peer-deps`
* Default: false
@@ -124,6 +138,18 @@ 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
@@ -132,7 +158,7 @@ this warning is treated as a failure.
If set to false, then ignore `package-lock.json` files when installing. This
will also prevent _writing_ `package-lock.json` if `save` is true.
This configuration does not affect `npm ci`.
#### `foreground-scripts`
@@ -146,6 +172,8 @@ 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
@@ -158,6 +186,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -168,6 +198,8 @@ 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
@@ -180,6 +212,8 @@ 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
@@ -189,6 +223,8 @@ 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
@@ -202,6 +238,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `workspace`
* Default:
@@ -264,6 +302,8 @@ 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)
+41 -1
View File
@@ -421,6 +421,8 @@ When used with the `npm rm` command, removes the dependency from
Will also prevent writing to `package-lock.json` if set to `false`.
#### `save-exact`
* Default: false
@@ -429,6 +431,8 @@ Will also prevent writing to `package-lock.json` if set to `false`.
Dependencies saved to package.json will be configured with an exact version
rather than using npm's default semver range operator.
#### `global`
* Default: false
@@ -443,6 +447,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `install-strategy`
* Default: "hoisted"
@@ -455,6 +461,8 @@ 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
@@ -467,6 +475,8 @@ 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
@@ -477,6 +487,8 @@ de-duplicating. Sets `--install-strategy=nested`.
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
@@ -495,6 +507,8 @@ 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.
#### `strict-peer-deps`
* Default: false
@@ -514,6 +528,18 @@ 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
@@ -522,7 +548,7 @@ this warning is treated as a failure.
If set to false, then ignore `package-lock.json` files when installing. This
will also prevent _writing_ `package-lock.json` if `save` is true.
This configuration does not affect `npm ci`.
#### `foreground-scripts`
@@ -536,6 +562,8 @@ 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
@@ -548,6 +576,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -558,6 +588,8 @@ 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
@@ -570,6 +602,8 @@ 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
@@ -579,6 +613,8 @@ 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
@@ -592,6 +628,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `workspace`
* Default:
@@ -654,6 +692,8 @@ 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}`,
+29 -1
View File
@@ -122,6 +122,8 @@ When used with the `npm rm` command, removes the dependency from
Will also prevent writing to `package-lock.json` if set to `false`.
#### `save-exact`
* Default: false
@@ -130,6 +132,8 @@ Will also prevent writing to `package-lock.json` if set to `false`.
Dependencies saved to package.json will be configured with an exact version
rather than using npm's default semver range operator.
#### `global`
* Default: false
@@ -144,6 +148,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `install-strategy`
* Default: "hoisted"
@@ -156,6 +162,8 @@ 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
@@ -168,6 +176,8 @@ 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
@@ -178,6 +188,8 @@ de-duplicating. Sets `--install-strategy=nested`.
Only install direct dependencies in the top level `node_modules`, but hoist
on deeper dependencies. Sets `--install-strategy=shallow`.
#### `strict-peer-deps`
* Default: false
@@ -197,6 +209,8 @@ 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
@@ -205,7 +219,7 @@ this warning is treated as a failure.
If set to false, then ignore `package-lock.json` files when installing. This
will also prevent _writing_ `package-lock.json` if `save` is true.
This configuration does not affect `npm ci`.
#### `omit`
@@ -225,6 +239,8 @@ 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.
#### `ignore-scripts`
* Default: false
@@ -237,6 +253,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -247,6 +265,8 @@ 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
@@ -259,6 +279,8 @@ 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
@@ -268,6 +290,8 @@ 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
@@ -281,6 +305,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `workspace`
* Default:
@@ -343,6 +369,8 @@ 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)
+5
View File
@@ -39,6 +39,8 @@ your existing record.
The base URL of the npm registry.
#### `scope`
* Default: the scope of the current project, if any, or ""
@@ -69,6 +71,7 @@ npm init --scope=@foo --yes
```
#### `auth-type`
* Default: "web"
@@ -77,6 +80,8 @@ npm init --scope=@foo --yes
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)
+3
View File
@@ -34,6 +34,8 @@ connected to that scope, if set.
The base URL of the npm registry.
#### `scope`
* Default: the scope of the current project, if any, or ""
@@ -64,6 +66,7 @@ npm init --scope=@foo --yes
```
### See Also
* [npm adduser](/commands/npm-adduser)
+23 -1
View File
@@ -27,7 +27,7 @@ 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@9.6.7 /path/to/npm
npm@9.7.1 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
```
@@ -82,6 +82,8 @@ 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
@@ -94,6 +96,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `long`
* Default: false
@@ -101,6 +105,8 @@ Not supported by all npm commands.
Show extended information in `ls`, `search`, and `help-search`.
#### `parseable`
* Default: false
@@ -109,6 +115,8 @@ Show extended information in `ls`, `search`, and `help-search`.
Output parseable results from commands that write to standard output. For
`npm search`, this will be tab-separated table format.
#### `global`
* Default: false
@@ -123,6 +131,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `depth`
* Default: `Infinity` if `--all` is set, otherwise `1`
@@ -133,6 +143,8 @@ 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
@@ -151,6 +163,8 @@ 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.
#### `link`
* Default: false
@@ -158,6 +172,8 @@ variable will be set to `'production'` for all lifecycle scripts.
Used with `npm ls`, limiting output to only those packages that are linked.
#### `package-lock-only`
* Default: false
@@ -172,6 +188,8 @@ 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,
@@ -181,6 +199,8 @@ For `list` this means the output will be based on the tree described by the
When set to true, npm uses unicode characters in the tree output. When
false, it uses ascii characters instead of unicode glyphs.
#### `workspace`
* Default:
@@ -243,6 +263,8 @@ 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)
+8
View File
@@ -69,6 +69,8 @@ listing them, and finding specific ones and their roles.
The base URL of the npm registry.
#### `otp`
* Default: null
@@ -80,6 +82,8 @@ 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
@@ -92,6 +96,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `parseable`
* Default: false
@@ -100,6 +106,8 @@ Not supported by all npm commands.
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)
+10
View File
@@ -95,6 +95,8 @@ 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
@@ -107,6 +109,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `long`
* Default: false
@@ -114,6 +118,8 @@ Not supported by all npm commands.
Show extended information in `ls`, `search`, and `help-search`.
#### `parseable`
* Default: false
@@ -122,6 +128,8 @@ Show extended information in `ls`, `search`, and `help-search`.
Output parseable results from commands that write to standard output. For
`npm search`, this will be tab-separated table format.
#### `global`
* Default: false
@@ -136,6 +144,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `workspace`
* Default:
+4
View File
@@ -42,6 +42,8 @@ flow when changing ownership or include an otp on the command line with `--otp`.
The base URL of the npm registry.
#### `otp`
* Default: null
@@ -53,6 +55,8 @@ 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:
+6
View File
@@ -25,6 +25,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `json`
* Default: false
@@ -37,6 +39,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `pack-destination`
* Default: "."
@@ -44,6 +48,8 @@ Not supported by all npm commands.
Directory in which `npm pack` will save tarballs.
#### `workspace`
* Default:
+2
View File
@@ -37,6 +37,8 @@ npm ERR! 404 Not Found - GET http://www.foo.com/-/ping?write=true
The base URL of the npm registry.
### See Also
* [npm doctor](/commands/npm-doctor)
+4
View File
@@ -201,6 +201,8 @@ mistakes, unnecessary performance degradation, and malicious input.
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
@@ -213,6 +215,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `workspace`
* Default:
+2
View File
@@ -49,6 +49,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
### See Also
* [npm root](/commands/npm-root)
+8
View File
@@ -81,6 +81,8 @@ Some of these commands may not be available on non npmjs.com registries.
The base URL of the npm registry.
#### `json`
* Default: false
@@ -93,6 +95,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `parseable`
* Default: false
@@ -101,6 +105,8 @@ Not supported by all npm commands.
Output parseable results from commands that write to standard output. For
`npm search`, this will be tab-separated table format.
#### `otp`
* Default: null
@@ -112,6 +118,8 @@ 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)
+12
View File
@@ -53,6 +53,8 @@ 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.
#### `dry-run`
* Default: false
@@ -66,6 +68,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `json`
* Default: false
@@ -78,6 +82,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `foreground-scripts`
* Default: false
@@ -90,6 +96,8 @@ 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
@@ -102,6 +110,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `workspace`
* Default:
@@ -164,6 +174,8 @@ 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)
+19
View File
@@ -101,6 +101,8 @@ 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.
#### `access`
* Default: 'public' for new packages, existing packages it will not change the
@@ -117,6 +119,8 @@ 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.
#### `dry-run`
* Default: false
@@ -130,6 +134,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `otp`
* Default: null
@@ -141,6 +147,8 @@ 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:
@@ -202,6 +210,17 @@ This value is not exported to the environment for child processes.
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 can not 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 can not be used with: `provenance`
### See Also
* [package spec](/using-npm/package-spec)
+2
View File
@@ -152,6 +152,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `workspace`
* Default:
+10
View File
@@ -39,6 +39,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `bin-links`
* Default: true
@@ -51,6 +53,8 @@ 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
@@ -63,6 +67,8 @@ 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
@@ -75,6 +81,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `workspace`
* Default:
@@ -137,6 +145,8 @@ 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)
+4
View File
@@ -32,6 +32,8 @@ terminal.
Set to `true` to use default system URL opener.
#### `registry`
* Default: "https://registry.npmjs.org/"
@@ -39,6 +41,8 @@ Set to `true` to use default system URL opener.
The base URL of the npm registry.
#### `workspace`
* Default:
+4
View File
@@ -48,6 +48,8 @@ Note that commands explicitly intended to run a particular script, such as
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
@@ -56,6 +58,8 @@ will *not* run any pre- or post-scripts.
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
init <package-spec>` commands.
### See Also
* [npm run-script](/commands/npm-run-script)
+2
View File
@@ -41,6 +41,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
### See Also
* [npm prefix](/commands/npm-prefix)
+6
View File
@@ -216,6 +216,8 @@ Note that commands explicitly intended to run a particular script, such as
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
@@ -228,6 +230,8 @@ 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
@@ -236,6 +240,8 @@ but can be useful for debugging.
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)
+22
View File
@@ -46,6 +46,8 @@ expression characters in most shells.)
Show extended information in `ls`, `search`, and `help-search`.
#### `json`
* Default: false
@@ -58,6 +60,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `color`
* Default: true unless the NO_COLOR environ is set to something other than '0'
@@ -66,6 +70,8 @@ Not supported by all npm commands.
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
@@ -74,6 +80,8 @@ true, then only prints color codes for tty file descriptors.
Output parseable results from commands that write to standard output. For
`npm search`, this will be tab-separated table format.
#### `description`
* Default: true
@@ -81,6 +89,8 @@ Output parseable results from commands that write to standard output. For
Show the description in `npm search`
#### `searchopts`
* Default: ""
@@ -88,6 +98,8 @@ Show the description in `npm search`
Space-separated options that are always passed to search.
#### `searchexclude`
* Default: ""
@@ -95,6 +107,8 @@ Space-separated options that are always passed to search.
Space-separated options that limit the results from search.
#### `registry`
* Default: "https://registry.npmjs.org/"
@@ -102,6 +116,8 @@ Space-separated options that limit the results from search.
The base URL of the npm registry.
#### `prefer-online`
* Default: false
@@ -110,6 +126,8 @@ The base URL of the npm registry.
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
@@ -119,6 +137,8 @@ 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
@@ -127,6 +147,8 @@ will be requested from the server. To force full offline mode, use
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)
+6
View File
@@ -42,6 +42,8 @@ You can see all your starred packages using [`npm stars`](/commands/npm-stars)
The base URL of the npm registry.
#### `unicode`
* Default: false on windows, true on mac/unix systems with a unicode locale,
@@ -51,6 +53,8 @@ The base URL of the npm registry.
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
@@ -62,6 +66,8 @@ 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)
+2
View File
@@ -29,6 +29,8 @@ you will most certainly enjoy this command.
The base URL of the npm registry.
### See Also
* [npm star](/commands/npm-star)
+4
View File
@@ -59,6 +59,8 @@ Note that commands explicitly intended to run a particular script, such as
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
@@ -67,6 +69,8 @@ will *not* run any pre- or post-scripts.
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
init <package-spec>` commands.
### See Also
* [npm run-script](/commands/npm-run-script)
+4
View File
@@ -52,6 +52,8 @@ Note that commands explicitly intended to run a particular script, such as
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
@@ -60,6 +62,8 @@ will *not* run any pre- or post-scripts.
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
init <package-spec>` commands.
### See Also
* [npm run-script](/commands/npm-run-script)
+8
View File
@@ -109,6 +109,8 @@ use the `npm access` command to grant or revoke the appropriate permissions.
The base URL of the npm registry.
#### `otp`
* Default: null
@@ -120,6 +122,8 @@ 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
@@ -128,6 +132,8 @@ password, npm will prompt on the command line for one.
Output parseable results from commands that write to standard output. For
`npm search`, this will be tab-separated table format.
#### `json`
* Default: false
@@ -140,6 +146,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
### See Also
* [npm access](/commands/npm-access)
+4
View File
@@ -49,6 +49,8 @@ Note that commands explicitly intended to run a particular script, such as
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
@@ -57,6 +59,8 @@ will *not* run any pre- or post-scripts.
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
init <package-spec>` commands.
### See Also
* [npm run-script](/commands/npm-run-script)
+8
View File
@@ -85,6 +85,8 @@ This lets you list, create and revoke authentication tokens.
This is used to mark a token as unable to publish when configuring limited
access tokens with the `npm token create` command.
#### `cidr`
* Default: null
@@ -93,6 +95,8 @@ access tokens with the `npm token create` command.
This is a list of CIDR address to be used when configuring limited access
tokens with the `npm token create` command.
#### `registry`
* Default: "https://registry.npmjs.org/"
@@ -100,6 +104,8 @@ tokens with the `npm token create` command.
The base URL of the npm registry.
#### `otp`
* Default: null
@@ -111,6 +117,8 @@ 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)
+20
View File
@@ -68,6 +68,24 @@ When used with the `npm rm` command, removes the dependency from
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:
@@ -130,6 +148,8 @@ 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)
+4
View File
@@ -52,6 +52,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `force`
* Default: false
@@ -78,6 +80,8 @@ mistakes, unnecessary performance degradation, and malicious input.
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:
+6
View File
@@ -38,6 +38,8 @@ You can see all your starred packages using [`npm stars`](/commands/npm-stars)
The base URL of the npm registry.
#### `unicode`
* Default: false on windows, true on mac/unix systems with a unicode locale,
@@ -47,6 +49,8 @@ The base URL of the npm registry.
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
@@ -58,6 +62,8 @@ 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)
+29 -1
View File
@@ -169,6 +169,8 @@ When used with the `npm rm` command, removes the dependency from
Will also prevent writing to `package-lock.json` if set to `false`.
#### `global`
* Default: false
@@ -183,6 +185,8 @@ folder instead of the current working directory. See
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
#### `install-strategy`
* Default: "hoisted"
@@ -195,6 +199,8 @@ 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
@@ -207,6 +213,8 @@ 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
@@ -217,6 +225,8 @@ de-duplicating. Sets `--install-strategy=nested`.
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
@@ -235,6 +245,8 @@ 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.
#### `strict-peer-deps`
* Default: false
@@ -254,6 +266,8 @@ 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
@@ -262,7 +276,7 @@ this warning is treated as a failure.
If set to false, then ignore `package-lock.json` files when installing. This
will also prevent _writing_ `package-lock.json` if `save` is true.
This configuration does not affect `npm ci`.
#### `foreground-scripts`
@@ -276,6 +290,8 @@ 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
@@ -288,6 +304,8 @@ Note that commands explicitly intended to run a particular script, such as
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
#### `audit`
* Default: true
@@ -298,6 +316,8 @@ 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
@@ -310,6 +330,8 @@ 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
@@ -319,6 +341,8 @@ 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
@@ -332,6 +356,8 @@ commands that modify your local installation, eg, `install`, `update`,
Note: This is NOT honored by other network related commands, eg `dist-tags`,
`owner`, etc.
#### `workspace`
* Default:
@@ -394,6 +420,8 @@ 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)
+14
View File
@@ -22,6 +22,8 @@ alias: verison
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
@@ -29,6 +31,8 @@ to the same value as the current version.
Run git commit hooks when using the `npm version` command.
#### `git-tag-version`
* Default: true
@@ -37,6 +41,8 @@ Run git commit hooks when using the `npm version` command.
Tag the commit when using the `npm version` command. Setting this to false
results in no commit being made at all.
#### `json`
* Default: false
@@ -49,6 +55,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `preid`
* Default: ""
@@ -57,6 +65,8 @@ Not supported by all npm commands.
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
@@ -68,6 +78,8 @@ If set to true, then the `npm version` command will tag the version using
Note that git requires you to have set up GPG keys in your git configs for
this to work properly.
#### `workspace`
* Default:
@@ -116,6 +128,8 @@ This value is not exported to the environment for child processes.
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
+2
View File
@@ -114,6 +114,8 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### `workspace`
* Default:
+2
View File
@@ -32,6 +32,8 @@ If logged into a registry that uses Basic Auth, then simply print the
The base URL of the npm registry.
### See Also
* [npm config](/commands/npm-config)
+1 -1
View File
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces.
### Version
9.6.7
9.7.1
### Description
File diff suppressed because it is too large. Load diff
+1 -9
View File
@@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#example">Example</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#example">Example</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@@ -257,14 +257,6 @@ the range set in their package's <code>peerDependencies</code> object.</p>
<p>When such an override is performed, a warning is printed, explaining the
conflict and the packages involved. If <code>--strict-peer-deps</code> is set, then
this warning is treated as a failure.</p>
<h4 id="package-lock"><code>package-lock</code></h4>
<ul>
<li>Default: true</li>
<li>Type: Boolean</li>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
-1
View File
@@ -249,7 +249,6 @@ this warning is treated as a failure.</p>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="omit"><code>omit</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
-1
View File
@@ -206,7 +206,6 @@ this warning is treated as a failure.</p>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="omit"><code>omit</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
+1 -9
View File
@@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@@ -214,14 +214,6 @@ the range set in their package's <code>peerDependencies</code> object.</p>
<p>When such an override is performed, a warning is printed, explaining the
conflict and the packages involved. If <code>--strict-peer-deps</code> is set, then
this warning is treated as a failure.</p>
<h4 id="package-lock"><code>package-lock</code></h4>
<ul>
<li>Default: true</li>
<li>Type: Boolean</li>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
+8 -2
View File
@@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#prefer-dedupe"><code>prefer-dedupe</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@@ -245,6 +245,13 @@ the range set in their package's <code>peerDependencies</code> object.</p>
<p>When such an override is performed, a warning is printed, explaining the
conflict and the packages involved. If <code>--strict-peer-deps</code> is set, then
this warning is treated as a failure.</p>
<h4 id="prefer-dedupe"><code>prefer-dedupe</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Prefer to deduplicate packages if possible, rather than choosing a newer
version of a dependency.</p>
<h4 id="package-lock"><code>package-lock</code></h4>
<ul>
<li>Default: true</li>
@@ -252,7 +259,6 @@ this warning is treated as a failure.</p>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
+8 -2
View File
@@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#algorithm">Algorithm</a></li><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#prefer-dedupe"><code>prefer-dedupe</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#algorithm">Algorithm</a></li><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@@ -571,6 +571,13 @@ the range set in their package's <code>peerDependencies</code> object.</p>
<p>When such an override is performed, a warning is printed, explaining the
conflict and the packages involved. If <code>--strict-peer-deps</code> is set, then
this warning is treated as a failure.</p>
<h4 id="prefer-dedupe"><code>prefer-dedupe</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Prefer to deduplicate packages if possible, rather than choosing a newer
version of a dependency.</p>
<h4 id="package-lock"><code>package-lock</code></h4>
<ul>
<li>Default: true</li>
@@ -578,7 +585,6 @@ this warning is treated as a failure.</p>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
-1
View File
@@ -301,7 +301,6 @@ this warning is treated as a failure.</p>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="omit"><code>omit</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
+1 -1
View File
@@ -160,7 +160,7 @@ tree at all, use <a href="../commands/npm-explain.html"><code>npm explain</code>
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@9.6.7 /path/to/npm
<pre><code class="language-bash">npm@9.7.1 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
</code></pre>
+9 -1
View File
@@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#files-included-in-package">Files included in package</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#tag"><code>tag</code></a></li><li><a href="#access"><code>access</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#otp"><code>otp</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#provenance"><code>provenance</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#files-included-in-package">Files included in package</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#tag"><code>tag</code></a></li><li><a href="#access"><code>access</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#otp"><code>otp</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#provenance"><code>provenance</code></a></li><li><a href="#provenance-file"><code>provenance-file</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@@ -313,6 +313,14 @@ the specified workspaces, and not on the root project.</p>
</ul>
<p>When publishing from a supported cloud CI/CD system, the package will be
publicly linked to where it was built and published from.</p>
<p>This config can not be used with: <code>provenance-file</code></p>
<h4 id="provenance-file"><code>provenance-file</code></h4>
<ul>
<li>Default: null</li>
<li>Type: Path</li>
</ul>
<p>When publishing, the provenance bundle at the given path will be used.</p>
<p>This config can not be used with: <code>provenance</code></p>
<h3 id="see-also">See Also</h3>
<ul>
<li><a href="../using-npm/package-spec.html">package spec</a></li>
+15 -1
View File
@@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#examples">Examples</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#examples">Examples</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@@ -187,6 +187,20 @@ it uninstalls the current package context as a global package.
<p>When used with the <code>npm rm</code> command, removes the dependency from
<code>package.json</code>.</p>
<p>Will also prevent writing to <code>package-lock.json</code> if set to <code>false</code>.</p>
<h4 id="global"><code>global</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Operates in "global" mode, so that packages are installed into the <code>prefix</code>
folder instead of the current working directory. See
<a href="../configuring-npm/folders.html">folders</a> for more on the differences in behavior.</p>
<ul>
<li>packages are installed into the <code>{prefix}/lib/node_modules</code> folder, instead
of the current working directory.</li>
<li>bin files are linked to <code>{prefix}/bin</code></li>
<li>man pages are linked to <code>{prefix}/share/man</code></li>
</ul>
<h4 id="workspace"><code>workspace</code></h4>
<ul>
<li>Default:</li>
-1
View File
@@ -342,7 +342,6 @@ this warning is treated as a failure.</p>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
+1 -1
View File
@@ -150,7 +150,7 @@ npm command-line interface
</code></pre>
<p>Note: This command is unaware of workspaces.</p>
<h3 id="version">Version</h3>
<p>9.6.7</p>
<p>9.7.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
+16 -2
View File
@@ -142,7 +142,7 @@ npm command-line interface
<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><ul><li><a href="#command-line-flags">Command Line Flags</a></li><li><a href="#environment-variables">Environment Variables</a></li><li><a href="#npmrc-files">npmrc Files</a></li><li><a href="#default-configs">Default Configs</a></li></ul><li><a href="#shorthands-and-other-cli-niceties">Shorthands and Other CLI Niceties</a></li><li><a href="#config-settings">Config Settings</a></li><ul><li><a href="#auth"><code>_auth</code></a></li><li><a href="#access"><code>access</code></a></li><li><a href="#all"><code>all</code></a></li><li><a href="#allow-same-version"><code>allow-same-version</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#audit-level"><code>audit-level</code></a></li><li><a href="#auth-type"><code>auth-type</code></a></li><li><a href="#before"><code>before</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#browser"><code>browser</code></a></li><li><a href="#ca"><code>ca</code></a></li><li><a href="#cache"><code>cache</code></a></li><li><a href="#cafile"><code>cafile</code></a></li><li><a href="#call"><code>call</code></a></li><li><a href="#cidr"><code>cidr</code></a></li><li><a href="#color"><code>color</code></a></li><li><a href="#commit-hooks"><code>commit-hooks</code></a></li><li><a href="#depth"><code>depth</code></a></li><li><a href="#description2"><code>description</code></a></li><li><a href="#diff"><code>diff</code></a></li><li><a href="#diff-dst-prefix"><code>diff-dst-prefix</code></a></li><li><a href="#diff-ignore-all-space"><code>diff-ignore-all-space</code></a></li><li><a href="#diff-name-only"><code>diff-name-only</code></a></li><li><a href="#diff-no-prefix"><code>diff-no-prefix</code></a></li><li><a href="#diff-src-prefix"><code>diff-src-prefix</code></a></li><li><a href="#diff-text"><code>diff-text</code></a></li><li><a href="#diff-unified"><code>diff-unified</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#editor"><code>editor</code></a></li><li><a href="#engine-strict"><code>engine-strict</code></a></li><li><a href="#fetch-retries"><code>fetch-retries</code></a></li><li><a href="#fetch-retry-factor"><code>fetch-retry-factor</code></a></li><li><a href="#fetch-retry-maxtimeout"><code>fetch-retry-maxtimeout</code></a></li><li><a href="#fetch-retry-mintimeout"><code>fetch-retry-mintimeout</code></a></li><li><a href="#fetch-timeout"><code>fetch-timeout</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#format-package-lock"><code>format-package-lock</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#git"><code>git</code></a></li><li><a href="#git-tag-version"><code>git-tag-version</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#globalconfig"><code>globalconfig</code></a></li><li><a href="#heading"><code>heading</code></a></li><li><a href="#https-proxy"><code>https-proxy</code></a></li><li><a href="#if-present"><code>if-present</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#include"><code>include</code></a></li><li><a href="#include-staged"><code>include-staged</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#init-author-email"><code>init-author-email</code></a></li><li><a href="#init-author-name"><code>init-author-name</code></a></li><li><a href="#init-author-url"><code>init-author-url</code></a></li><li><a href="#init-license"><code>init-license</code></a></li><li><a href="#init-module"><code>init-module</code></a></li><li><a href="#init-version"><code>init-version</code></a></li><li><a href="#install-links"><code>install-links</code></a></li><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#legacy-peer-deps"><code>legacy-peer-deps</code></a></li><li><a href="#link"><code>link</code></a></li><li><a href="#local-address"><code>local-address</code></a></li><li><a href="#location"><code>location</code></a></li><li><a href="#lockfile-version"><code>lockfile-version</code></a></li><li><a href="#loglevel"><code>loglevel</code></a></li><li><a href="#logs-dir"><code>logs-dir</code></a></li><li><a href="#logs-max"><code>logs-max</code></a></li><li><a href="#long"><code>long</code></a></li><li><a href="#maxsockets"><code>maxsockets</code></a></li><li><a href="#message"><code>message</code></a></li><li><a href="#node-options"><code>node-options</code></a></li><li><a href="#noproxy"><code>noproxy</code></a></li><li><a href="#offline"><code>offline</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#omit-lockfile-registry-resolved"><code>omit-lockfile-registry-resolved</code></a></li><li><a href="#otp"><code>otp</code></a></li><li><a href="#pack-destination"><code>packLine truncated
<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><ul><li><a href="#command-line-flags">Command Line Flags</a></li><li><a href="#environment-variables">Environment Variables</a></li><li><a href="#npmrc-files">npmrc Files</a></li><li><a href="#default-configs">Default Configs</a></li></ul><li><a href="#shorthands-and-other-cli-niceties">Shorthands and Other CLI Niceties</a></li><li><a href="#config-settings">Config Settings</a></li><ul><li><a href="#auth"><code>_auth</code></a></li><li><a href="#access"><code>access</code></a></li><li><a href="#all"><code>all</code></a></li><li><a href="#allow-same-version"><code>allow-same-version</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#audit-level"><code>audit-level</code></a></li><li><a href="#auth-type"><code>auth-type</code></a></li><li><a href="#before"><code>before</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#browser"><code>browser</code></a></li><li><a href="#ca"><code>ca</code></a></li><li><a href="#cache"><code>cache</code></a></li><li><a href="#cafile"><code>cafile</code></a></li><li><a href="#call"><code>call</code></a></li><li><a href="#cidr"><code>cidr</code></a></li><li><a href="#color"><code>color</code></a></li><li><a href="#commit-hooks"><code>commit-hooks</code></a></li><li><a href="#depth"><code>depth</code></a></li><li><a href="#description2"><code>description</code></a></li><li><a href="#diff"><code>diff</code></a></li><li><a href="#diff-dst-prefix"><code>diff-dst-prefix</code></a></li><li><a href="#diff-ignore-all-space"><code>diff-ignore-all-space</code></a></li><li><a href="#diff-name-only"><code>diff-name-only</code></a></li><li><a href="#diff-no-prefix"><code>diff-no-prefix</code></a></li><li><a href="#diff-src-prefix"><code>diff-src-prefix</code></a></li><li><a href="#diff-text"><code>diff-text</code></a></li><li><a href="#diff-unified"><code>diff-unified</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#editor"><code>editor</code></a></li><li><a href="#engine-strict"><code>engine-strict</code></a></li><li><a href="#fetch-retries"><code>fetch-retries</code></a></li><li><a href="#fetch-retry-factor"><code>fetch-retry-factor</code></a></li><li><a href="#fetch-retry-maxtimeout"><code>fetch-retry-maxtimeout</code></a></li><li><a href="#fetch-retry-mintimeout"><code>fetch-retry-mintimeout</code></a></li><li><a href="#fetch-timeout"><code>fetch-timeout</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#format-package-lock"><code>format-package-lock</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#git"><code>git</code></a></li><li><a href="#git-tag-version"><code>git-tag-version</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#globalconfig"><code>globalconfig</code></a></li><li><a href="#heading"><code>heading</code></a></li><li><a href="#https-proxy"><code>https-proxy</code></a></li><li><a href="#if-present"><code>if-present</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#include"><code>include</code></a></li><li><a href="#include-staged"><code>include-staged</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#init-author-email"><code>init-author-email</code></a></li><li><a href="#init-author-name"><code>init-author-name</code></a></li><li><a href="#init-author-url"><code>init-author-url</code></a></li><li><a href="#init-license"><code>init-license</code></a></li><li><a href="#init-module"><code>init-module</code></a></li><li><a href="#init-version"><code>init-version</code></a></li><li><a href="#install-links"><code>install-links</code></a></li><li><a href="#install-strategy"><code>install-strategy</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#legacy-peer-deps"><code>legacy-peer-deps</code></a></li><li><a href="#link"><code>link</code></a></li><li><a href="#local-address"><code>local-address</code></a></li><li><a href="#location"><code>location</code></a></li><li><a href="#lockfile-version"><code>lockfile-version</code></a></li><li><a href="#loglevel"><code>loglevel</code></a></li><li><a href="#logs-dir"><code>logs-dir</code></a></li><li><a href="#logs-max"><code>logs-max</code></a></li><li><a href="#long"><code>long</code></a></li><li><a href="#maxsockets"><code>maxsockets</code></a></li><li><a href="#message"><code>message</code></a></li><li><a href="#node-options"><code>node-options</code></a></li><li><a href="#noproxy"><code>noproxy</code></a></li><li><a href="#offline"><code>offline</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#omit-lockfile-registry-resolved"><code>omit-lockfile-registry-resolved</code></a></li><li><a href="#otp"><code>otp</code></a></li><li><a href="#pack-destination"><code>packLine truncated
</section>
<div id="_content"><h3 id="description">Description</h3>
@@ -922,7 +922,6 @@ password, npm will prompt on the command line for one.</p>
</ul>
<p>If set to false, then ignore <code>package-lock.json</code> files when installing. This
will also prevent <em>writing</em> <code>package-lock.json</code> if <code>save</code> is true.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<h4 id="package-lock-only"><code>package-lock-only</code></h4>
<ul>
<li>Default: false</li>
@@ -941,6 +940,13 @@ instead of checking <code>node_modules</code> and downloading dependencies.</p>
</ul>
<p>Output parseable results from commands that write to standard output. For
<code>npm search</code>, this will be tab-separated table format.</p>
<h4 id="prefer-dedupe"><code>prefer-dedupe</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Prefer to deduplicate packages if possible, rather than choosing a newer
version of a dependency.</p>
<h4 id="prefer-offline"><code>prefer-offline</code></h4>
<ul>
<li>Default: false</li>
@@ -987,6 +993,14 @@ operations, if <code>process.stderr</code> is a TTY.</p>
</ul>
<p>When publishing from a supported cloud CI/CD system, the package will be
publicly linked to where it was built and published from.</p>
<p>This config can not be used with: <code>provenance-file</code></p>
<h4 id="provenance-file"><code>provenance-file</code></h4>
<ul>
<li>Default: null</li>
<li>Type: Path</li>
</ul>
<p>When publishing, the provenance bundle at the given path will be used.</p>
<p>This config can not be used with: <code>provenance</code></p>
<h4 id="proxy"><code>proxy</code></h4>
<ul>
<li>Default: null</li>
+69 -57
View File
@@ -2,17 +2,81 @@
const { relative } = require('path')
const ConfigDefinitions = require('./utils/config/definitions.js')
const definitions = require('./utils/config/definitions.js')
const getWorkspaces = require('./workspaces/get-workspaces.js')
const cmdAliases = require('./utils/cmd-list').aliases
const { aliases: cmdAliases } = require('./utils/cmd-list')
class BaseCommand {
static workspaces = false
static ignoreImplicitWorkspace = true
// these are all overridden by individual commands
static name = null
static description = null
static params = null
// this is a static so that we can read from it without instantiating a command
// which would require loading the config
static get describeUsage () {
const seenExclusive = new Set()
const wrapWidth = 80
const { description, usage = [''], name, params } = this
const fullUsage = [
`${description}`,
'',
'Usage:',
...usage.map(u => `npm ${name} ${u}`.trim()),
]
if (params) {
let results = ''
let line = ''
for (const param of params) {
/* istanbul ignore next */
if (seenExclusive.has(param)) {
continue
}
const { exclusive } = definitions[param]
let paramUsage = `${definitions[param].usage}`
if (exclusive) {
const exclusiveParams = [paramUsage]
seenExclusive.add(param)
for (const e of exclusive) {
seenExclusive.add(e)
exclusiveParams.push(definitions[e].usage)
}
paramUsage = `${exclusiveParams.join('|')}`
}
paramUsage = `[${paramUsage}]`
if (line.length + paramUsage.length > wrapWidth) {
results = [results, line].filter(Boolean).join('\n')
line = ''
}
line = [line, paramUsage].filter(Boolean).join(' ')
}
fullUsage.push('')
fullUsage.push('Options:')
fullUsage.push([results, line].filter(Boolean).join('\n'))
}
const aliases = Object.entries(cmdAliases).reduce((p, [k, v]) => {
return p.concat(v === name ? k : [])
}, [])
if (aliases.length) {
const plural = aliases.length === 1 ? '' : 'es'
fullUsage.push('')
fullUsage.push(`alias${plural}: ${aliases.join(', ')}`)
}
fullUsage.push('')
fullUsage.push(`Run "npm help ${name}" for more info`)
return fullUsage.join('\n')
}
constructor (npm) {
this.wrapWidth = 80
this.npm = npm
const { config } = this.npm
@@ -39,59 +103,7 @@ class BaseCommand {
}
get usage () {
const usage = [
`${this.description}`,
'',
'Usage:',
]
if (!this.constructor.usage) {
usage.push(`npm ${this.name}`)
} else {
usage.push(...this.constructor.usage.map(u => `npm ${this.name} ${u}`))
}
if (this.params) {
usage.push('')
usage.push('Options:')
usage.push(this.wrappedParams)
}
const aliases = Object.keys(cmdAliases).reduce((p, c) => {
if (cmdAliases[c] === this.name) {
p.push(c)
}
return p
}, [])
if (aliases.length === 1) {
usage.push('')
usage.push(`alias: ${aliases.join(', ')}`)
} else if (aliases.length > 1) {
usage.push('')
usage.push(`aliases: ${aliases.join(', ')}`)
}
usage.push('')
usage.push(`Run "npm help ${this.name}" for more info`)
return usage.join('\n')
}
get wrappedParams () {
let results = ''
let line = ''
for (const param of this.params) {
const usage = `[${ConfigDefinitions[param].usage}]`
if (line.length && line.length + usage.length > this.wrapWidth) {
results = [results, line].filter(Boolean).join('\n')
line = ''
}
line = [line, usage].filter(Boolean).join(' ')
}
results = [results, line].filter(Boolean).join('\n')
return results
return this.constructor.describeUsage
}
usageError (prefix = '') {
+74
View File
@@ -0,0 +1,74 @@
/* eslint-disable max-len */
// 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
process.title = 'npm'
// if npm is called as "npmg" or "npm_g", then run in global mode.
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}
const satisfies = require('semver/functions/satisfies')
const exitHandler = require('./utils/exit-handler.js')
const Npm = require('./npm.js')
const npm = new Npm()
exitHandler.setNpm(npm)
// only log node and npm paths in argv initially since argv can contain sensitive info. a cleaned version will be logged later
const log = require('./utils/log-shim.js')
log.verbose('cli', process.argv.slice(0, 2).join(' '))
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 dont 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()
process.on('uncaughtException', exitHandler)
process.on('unhandledRejection', exitHandler)
// 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)
}
let cmd
// Now actually fire up npm and run the command.
// This is how to use npm programmatically:
try {
await npm.load()
// npm -v
if (npm.config.get('version', 'cli')) {
npm.output(npm.version)
return exitHandler()
}
// npm --versions
if (npm.config.get('versions', 'cli')) {
npm.argv = ['version']
npm.config.set('usage', false, 'cli')
}
cmd = npm.argv.shift()
if (!cmd) {
npm.output(npm.usage)
process.exitCode = 1
return exitHandler()
}
await npm.exec(cmd)
return exitHandler()
} catch (err) {
if (err.code === 'EUNKNOWNCOMMAND') {
const didYouMean = require('./utils/did-you-mean.js')
const suggestions = await didYouMean(npm.localPrefix, cmd)
npm.output(`Unknown command: "${cmd}"${suggestions}\n`)
npm.output('To see a list of supported npm commands, run:\n npm help')
process.exitCode = 1
return exitHandler()
}
return exitHandler(err)
}
}
+3 -101
View File
@@ -1,102 +1,4 @@
/* eslint-disable max-len */
// Code in this file should work in all conceivably runnable versions of node.
// A best effort is made to catch syntax errors to give users a good error message if they are using a node version that doesn't allow syntax we are using in other files such as private properties, etc
const validateEngines = require('./es6/validate-engines.js')
const cliEntry = require('path').resolve(__dirname, 'cli-entry.js')
// Separated out for easier unit testing
module.exports = async process => {
// set it here so that regardless of what happens later, we don't
// leak any private CLI configs to other programs
process.title = 'npm'
// if npm is called as "npmg" or "npm_g", then run in global mode.
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}
const nodeVersion = process.version.replace(/-.*$/, '')
const pkg = require('../package.json')
const engines = pkg.engines.node
const npmVersion = `v${pkg.version}`
const unsupportedMessage = `npm ${npmVersion} does not support Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
const brokenMessage = `ERROR: npm ${npmVersion} is known not to run on Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
// Coverage ignored because this is only hit in very unsupported node versions and it's a best effort attempt to show something nice in those cases
/* istanbul ignore next */
const syntaxErrorHandler = (err) => {
if (err instanceof SyntaxError) {
// eslint-disable-next-line no-console
console.error(`${brokenMessage}\n\nERROR:`)
// eslint-disable-next-line no-console
console.error(err)
return process.exit(1)
}
throw err
}
process.on('uncaughtException', syntaxErrorHandler)
process.on('unhandledRejection', syntaxErrorHandler)
const satisfies = require('semver/functions/satisfies')
const exitHandler = require('./utils/exit-handler.js')
const Npm = require('./npm.js')
const npm = new Npm()
exitHandler.setNpm(npm)
// only log node and npm paths in argv initially since argv can contain sensitive info. a cleaned version will be logged later
const log = require('./utils/log-shim.js')
log.verbose('cli', process.argv.slice(0, 2).join(' '))
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 dont 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.
process.off('uncaughtException', syntaxErrorHandler)
process.off('unhandledRejection', syntaxErrorHandler)
process.on('uncaughtException', exitHandler)
process.on('unhandledRejection', exitHandler)
// 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(nodeVersion, engines)) {
log.warn('cli', unsupportedMessage)
}
let cmd
// Now actually fire up npm and run the command.
// This is how to use npm programmatically:
try {
await npm.load()
// npm -v
if (npm.config.get('version', 'cli')) {
npm.output(npm.version)
return exitHandler()
}
// npm --versions
if (npm.config.get('versions', 'cli')) {
npm.argv = ['version']
npm.config.set('usage', false, 'cli')
}
cmd = npm.argv.shift()
if (!cmd) {
npm.output(await npm.usage)
process.exitCode = 1
return exitHandler()
}
await npm.exec(cmd)
return exitHandler()
} catch (err) {
if (err.code === 'EUNKNOWNCOMMAND') {
const didYouMean = require('./utils/did-you-mean.js')
const suggestions = await didYouMean(npm, npm.localPrefix, cmd)
npm.output(`Unknown command: "${cmd}"${suggestions}\n`)
npm.output('To see a list of supported npm commands, run:\n npm help')
process.exitCode = 1
return exitHandler()
}
return exitHandler(err)
}
}
module.exports = (process) => validateEngines(process, () => require(cliEntry))
+4 -6
View File
@@ -1,8 +1,6 @@
const path = require('path')
const libnpmaccess = require('libnpmaccess')
const npa = require('npm-package-arg')
const readPackageJson = require('read-package-json-fast')
const pkgJson = require('@npmcli/package-json')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const otplease = require('../utils/otplease.js')
@@ -47,7 +45,7 @@ class Access extends BaseCommand {
'revoke <scope:team> [<package>]',
]
async completion (opts) {
static async completion (opts) {
const argv = opts.conf.argv.remain
if (argv.length === 2) {
return commands
@@ -178,8 +176,8 @@ class Access extends BaseCommand {
async #getPackage (name, requireScope) {
if (!name) {
try {
const pkg = await readPackageJson(path.resolve(this.npm.prefix, 'package.json'))
name = pkg.name
const { content } = await pkgJson.normalize(this.npm.prefix)
name = content.name
} catch (err) {
if (err.code === 'ENOENT') {
throw Object.assign(new Error('no package name given and no package.json found'), {
+49 -18
View File
@@ -1,9 +1,10 @@
const auditReport = require('npm-audit-report')
const npmAuditReport = require('npm-audit-report')
const fetch = require('npm-registry-fetch')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const npa = require('npm-package-arg')
const pacote = require('pacote')
const pMap = require('p-map')
const { sigstore } = require('sigstore')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
const auditError = require('../utils/audit-error.js')
@@ -37,7 +38,12 @@ class VerifySignatures {
throw new Error('found no installed dependencies to audit')
}
await Promise.all([...registries].map(registry => this.setKeys({ registry })))
const tuf = await sigstore.tuf.client({
tufCachePath: this.opts.tufCache,
retry: this.opts.retry,
timeout: this.opts.timeout,
})
await Promise.all([...registries].map(registry => this.setKeys({ registry, tuf })))
const progress = log.newItem('verifying registry signatures', edges.size)
const mapper = async (edge) => {
@@ -187,20 +193,42 @@ class VerifySignatures {
return { edges, registries }
}
async setKeys ({ registry }) {
const keys = await fetch.json('/-/npm/v1/keys', {
...this.npm.flatOptions,
registry,
}).then(({ keys: ks }) => ks.map((key) => ({
...key,
pemkey: `-----BEGIN PUBLIC KEY-----\n${key.key}\n-----END PUBLIC KEY-----`,
}))).catch(err => {
if (err.code === 'E404' || err.code === 'E400') {
return null
} else {
throw err
}
})
async setKeys ({ registry, tuf }) {
const { host, pathname } = new URL(registry)
// Strip any trailing slashes from pathname
const regKey = `${host}${pathname.replace(/\/$/, '')}/keys.json`
let keys = await tuf.getTarget(regKey)
.then((target) => JSON.parse(target))
.then(({ keys: ks }) => ks.map((key) => ({
...key,
keyid: key.keyId,
pemkey: `-----BEGIN PUBLIC KEY-----\n${key.publicKey.rawBytes}\n-----END PUBLIC KEY-----`,
expires: key.publicKey.validFor.end || null,
}))).catch(err => {
if (err.code === 'TUF_FIND_TARGET_ERROR') {
return null
} else {
throw err
}
})
// If keys not found in Sigstore TUF repo, fallback to registry keys API
if (!keys) {
keys = await fetch.json('/-/npm/v1/keys', {
...this.npm.flatOptions,
registry,
}).then(({ keys: ks }) => ks.map((key) => ({
...key,
pemkey: `-----BEGIN PUBLIC KEY-----\n${key.key}\n-----END PUBLIC KEY-----`,
}))).catch(err => {
if (err.code === 'E404' || err.code === 'E400') {
return null
} else {
throw err
}
})
}
if (keys) {
this.keys.set(registry, keys)
}
@@ -384,7 +412,7 @@ class Audit extends ArboristWorkspaceCmd {
static usage = ['[fix|signatures]']
async completion (opts) {
static async completion (opts) {
const argv = opts.conf.argv.remain
if (argv.length === 2) {
@@ -429,7 +457,10 @@ class Audit extends ArboristWorkspaceCmd {
} else {
// will throw if there's an error, because this is an audit command
auditError(this.npm, arb.auditReport)
const result = auditReport(arb.auditReport, opts)
const result = npmAuditReport(arb.auditReport, {
...opts,
chalk: this.npm.chalk,
})
process.exitCode = process.exitCode || result.exitCode
this.npm.output(result.report)
}
+1 -1
View File
@@ -73,7 +73,7 @@ class Cache extends BaseCommand {
'verify',
]
async completion (opts) {
static async completion (opts) {
const argv = opts.conf.argv.remain
if (argv.length === 2) {
return ['add', 'clean', 'verify', 'ls']
-1
View File
@@ -17,7 +17,6 @@ class CI extends ArboristWorkspaceCmd {
'global-style',
'omit',
'strict-peer-deps',
'package-lock',
'foreground-scripts',
'ignore-scripts',
'audit',
+12 -7
View File
@@ -33,8 +33,9 @@ const fs = require('fs/promises')
const nopt = require('nopt')
const { resolve } = require('path')
const Npm = require('../npm.js')
const { definitions, shorthands } = require('../utils/config/index.js')
const { commands, aliases } = require('../utils/cmd-list.js')
const { commands, aliases, deref } = require('../utils/cmd-list.js')
const configNames = Object.keys(definitions)
const shorthandNames = Object.keys(shorthands)
const allConfs = configNames.concat(shorthandNames)
@@ -48,7 +49,7 @@ class Completion extends BaseCommand {
static name = 'completion'
// completion for the completion command
async completion (opts) {
static async completion (opts) {
if (opts.w > 2) {
return
}
@@ -156,10 +157,14 @@ class Completion extends BaseCommand {
// at this point, if words[1] is some kind of npm command,
// then complete on it.
// otherwise, do nothing
const impl = await this.npm.cmd(cmd)
if (impl.completion) {
const comps = await impl.completion(opts)
return this.wrap(opts, comps)
try {
const { completion } = Npm.cmd(cmd)
if (completion) {
const comps = await completion(opts, this.npm)
return this.wrap(opts, comps)
}
} catch {
// it wasnt a valid command, so do nothing
}
}
@@ -267,7 +272,7 @@ const cmdCompl = (opts, npm) => {
return matches
}
const derefs = new Set([...matches.map(c => npm.deref(c))])
const derefs = new Set([...matches.map(c => deref(c))])
if (derefs.size === 1) {
return [...derefs]
}
+7 -7
View File
@@ -7,7 +7,7 @@ const { spawn } = require('child_process')
const { EOL } = require('os')
const ini = require('ini')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const rpj = require('read-package-json-fast')
const pkgJson = require('@npmcli/package-json')
const log = require('../utils/log-shim.js')
// These are the configs that we can nerf-dart. Not all of them currently even
@@ -74,7 +74,7 @@ class Config extends BaseCommand {
static skipConfigValidation = true
async completion (opts) {
static async completion (opts) {
const argv = opts.conf.argv.remain
if (argv[1] !== 'config') {
argv.unshift('config')
@@ -346,15 +346,15 @@ ${defData}
}
if (!this.npm.global) {
const pkgPath = resolve(this.npm.prefix, 'package.json')
const pkg = await rpj(pkgPath).catch(() => ({}))
const { content } = await pkgJson.normalize(this.npm.prefix).catch(() => ({ content: {} }))
if (pkg.publishConfig) {
if (content.publishConfig) {
const pkgPath = resolve(this.npm.prefix, 'package.json')
msg.push(`; "publishConfig" from ${pkgPath}`)
msg.push('; This set of config values will be used at publish-time.', '')
const pkgKeys = Object.keys(pkg.publishConfig).sort(localeCompare)
const pkgKeys = Object.keys(content.publishConfig).sort(localeCompare)
for (const k of pkgKeys) {
const v = publicVar(k) ? JSON.stringify(pkg.publishConfig[k]) : '(protected)'
const v = publicVar(k) ? JSON.stringify(content.publishConfig[k]) : '(protected)'
msg.push(`${k} = ${v}`)
}
msg.push('')
+3 -3
View File
@@ -17,13 +17,13 @@ class Deprecate extends BaseCommand {
static ignoreImplicitWorkspace = false
async completion (opts) {
static async completion (opts, npm) {
if (opts.conf.argv.remain.length > 1) {
return []
}
const username = await getIdentity(this.npm, this.npm.flatOptions)
const packages = await libaccess.getPackages(username, this.npm.flatOptions)
const username = await getIdentity(npm, npm.flatOptions)
const packages = await libaccess.getPackages(username, npm.flatOptions)
return Object.keys(packages)
.filter((name) =>
packages[name] === 'write' &&
+4 -4
View File
@@ -5,7 +5,7 @@ const npa = require('npm-package-arg')
const pacote = require('pacote')
const pickManifest = require('npm-pick-manifest')
const log = require('../utils/log-shim')
const readPackage = require('read-package-json-fast')
const pkgJson = require('@npmcli/package-json')
const BaseCommand = require('../base-command.js')
class Diff extends BaseCommand {
@@ -81,7 +81,7 @@ class Diff extends BaseCommand {
async packageName (path) {
let name
try {
const pkg = await readPackage(resolve(this.prefix, 'package.json'))
const { content: pkg } = await pkgJson.normalize(this.prefix)
name = pkg.name
} catch (e) {
log.verbose('diff', 'could not read project dir package.json')
@@ -115,7 +115,7 @@ class Diff extends BaseCommand {
let noPackageJson
let pkgName
try {
const pkg = await readPackage(resolve(this.prefix, 'package.json'))
const { content: pkg } = await pkgJson.normalize(this.prefix)
pkgName = pkg.name
} catch (e) {
log.verbose('diff', 'could not read project dir package.json')
@@ -228,7 +228,7 @@ class Diff extends BaseCommand {
if (semverA && semverB) {
let pkgName
try {
const pkg = await readPackage(resolve(this.prefix, 'package.json'))
const { content: pkg } = await pkgJson.normalize(this.prefix)
pkgName = pkg.name
} catch (e) {
log.verbose('diff', 'could not read project dir package.json')
+3 -4
View File
@@ -1,10 +1,9 @@
const npa = require('npm-package-arg')
const path = require('path')
const regFetch = require('npm-registry-fetch')
const semver = require('semver')
const log = require('../utils/log-shim')
const otplease = require('../utils/otplease.js')
const readPackage = require('read-package-json-fast')
const pkgJson = require('@npmcli/package-json')
const BaseCommand = require('../base-command.js')
class DistTag extends BaseCommand {
@@ -20,7 +19,7 @@ class DistTag extends BaseCommand {
static workspaces = true
static ignoreImplicitWorkspace = false
async completion (opts) {
static async completion (opts) {
const argv = opts.conf.argv.remain
if (argv.length === 2) {
return ['add', 'rm', 'ls']
@@ -152,7 +151,7 @@ class DistTag extends BaseCommand {
if (this.npm.global) {
throw this.usageError()
}
const { name } = await readPackage(path.resolve(this.npm.prefix, 'package.json'))
const { content: { name } } = await pkgJson.normalize(this.npm.prefix)
if (!name) {
throw this.usageError()
}
+2 -2
View File
@@ -38,8 +38,8 @@ class Edit extends BaseCommand {
// TODO
/* istanbul ignore next */
async completion (opts) {
return completion(this.npm, opts)
static async completion (opts, npm) {
return completion(npm, opts)
}
async exec (args) {
+2
View File
@@ -54,6 +54,7 @@ class Exec extends BaseCommand {
localBin,
globalBin,
globalDir,
chalk,
} = this.npm
const output = this.npm.output.bind(this.npm)
const scriptShell = this.npm.config.get('script-shell') || undefined
@@ -83,6 +84,7 @@ class Exec extends BaseCommand {
globalBin,
globalPath,
output,
chalk,
packages,
path: localPrefix,
runPath,
+2 -2
View File
@@ -18,9 +18,9 @@ class Explain extends ArboristWorkspaceCmd {
// TODO
/* istanbul ignore next */
async completion (opts) {
static async completion (opts, npm) {
const completion = require('../utils/completion/installed-deep.js')
return completion(this.npm, opts)
return completion(npm, opts)
}
async exec (args) {
+5 -5
View File
@@ -1,9 +1,9 @@
// npm explore <pkg>[@<version>]
// open a subshell to the package folder.
const rpj = require('read-package-json-fast')
const pkgJson = require('@npmcli/package-json')
const runScript = require('@npmcli/run-script')
const { join, resolve, relative } = require('path')
const { join, relative } = require('path')
const log = require('../utils/log-shim.js')
const completion = require('../utils/completion/installed-shallow.js')
const BaseCommand = require('../base-command.js')
@@ -17,8 +17,8 @@ class Explore extends BaseCommand {
// TODO
/* istanbul ignore next */
async completion (opts) {
return completion(this.npm, opts)
static async completion (opts, npm) {
return completion(npm, opts)
}
async exec (args) {
@@ -38,7 +38,7 @@ class Explore extends BaseCommand {
// the set of arguments, or the shell config, and let @npmcli/run-script
// handle all the escaping and PATH setup stuff.
const pkg = await rpj(resolve(path, 'package.json')).catch(er => {
const { content: pkg } = await pkgJson.normalize(path).catch(er => {
log.error('explore', `It doesn't look like ${pkgname} is installed.`)
throw er
})
+2 -2
View File
@@ -36,9 +36,9 @@ class Fund extends ArboristWorkspaceCmd {
// TODO
/* istanbul ignore next */
async completion (opts) {
static async completion (opts, npm) {
const completion = require('../utils/completion/installed-deep.js')
return completion(this.npm, opts)
return completion(npm, opts)
}
async exec (args) {
+5 -3
View File
@@ -1,16 +1,18 @@
const Npm = require('../npm.js')
const BaseCommand = require('../base-command.js')
class Get extends BaseCommand {
static description = 'Get a value from the npm configuration'
static name = 'get'
static usage = ['[<key> ...] (See `npm config`)']
static params = ['long']
static ignoreImplicitWorkspace = false
// TODO
/* istanbul ignore next */
async completion (opts) {
const config = await this.npm.cmd('config')
return config.completion(opts)
static async completion (opts) {
const Config = Npm.cmd('config')
return Config.completion(opts)
}
async exec (args) {
+5 -4
View File
@@ -3,6 +3,7 @@ const path = require('path')
const openUrl = require('../utils/open-url.js')
const { glob } = require('glob')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const { deref } = require('../utils/cmd-list.js')
const globify = pattern => pattern.split('\\').join('/')
const BaseCommand = require('../base-command.js')
@@ -26,11 +27,11 @@ class Help extends BaseCommand {
static usage = ['<term> [<terms..>]']
static params = ['viewer']
async completion (opts) {
static async completion (opts, npm) {
if (opts.conf.argv.remain.length > 2) {
return []
}
const g = path.resolve(this.npm.npmRoot, 'man/man[0-9]/*.[0-9]')
const g = path.resolve(npm.npmRoot, 'man/man[0-9]/*.[0-9]')
let files = await glob(globify(g))
// preserve glob@8 behavior
files = files.sort((a, b) => a.localeCompare(b, 'en'))
@@ -49,7 +50,7 @@ class Help extends BaseCommand {
const manSearch = /^\d+$/.test(args[0]) ? `man${args.shift()}` : 'man*'
if (!args.length) {
return this.npm.output(await this.npm.usage)
return this.npm.output(this.npm.usage)
}
// npm help foo bar baz: search topics
@@ -58,7 +59,7 @@ class Help extends BaseCommand {
}
// `npm help package.json`
const arg = (this.npm.deref(args[0]) || args[0]).replace('.json', '-json')
const arg = (deref(args[0]) || args[0]).replace('.json', '-json')
// find either section.n or npm-section.n
const f = globify(path.resolve(this.npm.npmRoot, `man/${manSearch}/?(npm-)${arg}.[0-9]*`))
+4 -5
View File
@@ -3,7 +3,6 @@ const { relative, resolve } = require('path')
const { mkdir } = require('fs/promises')
const initJson = require('init-package-json')
const npa = require('npm-package-arg')
const rpj = require('read-package-json-fast')
const libexec = require('libnpmexec')
const mapWorkspaces = require('@npmcli/map-workspaces')
const PackageJson = require('@npmcli/package-json')
@@ -54,7 +53,7 @@ class Init extends BaseCommand {
// reads package.json for the top-level folder first, by doing this we
// ensure the command throw if no package.json is found before trying
// to create a workspace package.json file or its folders
const pkg = await rpj(resolve(this.npm.localPrefix, 'package.json')).catch((err) => {
const { content: pkg } = await PackageJson.normalize(this.npm.localPrefix).catch(err => {
if (err.code === 'ENOENT') {
log.warn('Missing package.json. Try with `--include-workspace-root`.')
}
@@ -120,11 +119,11 @@ class Init extends BaseCommand {
}
const newArgs = [packageName, ...otherArgs]
const { color } = this.npm.flatOptions
const {
flatOptions,
localBin,
globalBin,
chalk,
} = this.npm
const output = this.npm.output.bind(this.npm)
const runPath = path
@@ -134,10 +133,10 @@ class Init extends BaseCommand {
await libexec({
...flatOptions,
args: newArgs,
color,
localBin,
globalBin,
output,
chalk,
path,
runPath,
scriptShell,
@@ -217,7 +216,7 @@ class Init extends BaseCommand {
// translate workspaces paths into an array containing workspaces names
const workspaces = []
for (const path of workspacesPaths) {
const { name } = await rpj(resolve(path, 'package.json')).catch(() => ({}))
const { content: { name } } = await PackageJson.normalize(path).catch(() => ({ content: {} }))
if (name) {
workspaces.push(name)
+2 -1
View File
@@ -25,6 +25,7 @@ class Install extends ArboristWorkspaceCmd {
'global-style',
'omit',
'strict-peer-deps',
'prefer-dedupe',
'package-lock',
'foreground-scripts',
'ignore-scripts',
@@ -37,7 +38,7 @@ class Install extends ArboristWorkspaceCmd {
static usage = ['[<package-spec> ...]']
async completion (opts) {
static async completion (opts) {
const { partialWord } = opts
// install can complete to a folder with a package.json, or any package.
// if it has a slash, then it's gotta be a folder
+9 -8
View File
@@ -4,7 +4,7 @@ const readdir = util.promisify(fs.readdir)
const { resolve } = require('path')
const npa = require('npm-package-arg')
const rpj = require('read-package-json-fast')
const pkgJson = require('@npmcli/package-json')
const semver = require('semver')
const reifyFinish = require('../utils/reify-finish.js')
@@ -35,8 +35,8 @@ class Link extends ArboristWorkspaceCmd {
...super.params,
]
async completion (opts) {
const dir = this.npm.globalDir
static async completion (opts, npm) {
const dir = npm.globalDir
const files = await readdir(dir)
return files.filter(f => !/^[._-]/.test(f))
}
@@ -96,11 +96,12 @@ class Link extends ArboristWorkspaceCmd {
const names = []
for (const a of args) {
const arg = npa(a)
names.push(
arg.type === 'directory'
? (await rpj(resolve(arg.fetchSpec, 'package.json'))).name
: arg.name
)
if (arg.type === 'directory') {
const { content } = await pkgJson.normalize(arg.fetchSpec)
names.push(content.name)
} else {
names.push(arg.name)
}
}
// npm link should not save=true by default unless you're
+2 -2
View File
@@ -40,9 +40,9 @@ class LS extends ArboristWorkspaceCmd {
// TODO
/* istanbul ignore next */
async completion (opts) {
static async completion (opts, npm) {
const completion = require('../utils/completion/installed-deep.js')
return completion(this.npm, opts)
return completion(npm, opts)
}
async exec (args) {
+1 -1
View File
@@ -14,7 +14,7 @@ class Org extends BaseCommand {
static params = ['registry', 'otp', 'json', 'parseable']
async completion (opts) {
static async completion (opts) {
const argv = opts.conf.argv.remain
if (argv.length === 2) {
return ['set', 'rm', 'ls']
+9 -10
View File
@@ -3,14 +3,13 @@ const npmFetch = require('npm-registry-fetch')
const pacote = require('pacote')
const log = require('../utils/log-shim')
const otplease = require('../utils/otplease.js')
const readPackageJsonFast = require('read-package-json-fast')
const pkgJson = require('@npmcli/package-json')
const BaseCommand = require('../base-command.js')
const { resolve } = require('path')
const readJson = async (pkg) => {
const readJson = async (path) => {
try {
const json = await readPackageJsonFast(pkg)
return json
const { content } = await pkgJson.normalize(path)
return content
} catch {
return {}
}
@@ -35,7 +34,7 @@ class Owner extends BaseCommand {
static workspaces = true
static ignoreImplicitWorkspace = false
async completion (opts) {
static async completion (opts, npm) {
const argv = opts.conf.argv.remain
if (argv.length > 3) {
return []
@@ -51,17 +50,17 @@ class Owner extends BaseCommand {
// reaches registry in order to autocomplete rm
if (argv[2] === 'rm') {
if (this.npm.global) {
if (npm.global) {
return []
}
const { name } = await readJson(resolve(this.npm.prefix, 'package.json'))
const { name } = await readJson(npm.prefix)
if (!name) {
return []
}
const spec = npa(name)
const data = await pacote.packument(spec, {
...this.npm.flatOptions,
...npm.flatOptions,
fullMetadata: true,
})
if (data && data.maintainers && data.maintainers.length) {
@@ -130,7 +129,7 @@ class Owner extends BaseCommand {
if (this.npm.global) {
throw this.usageError()
}
const { name } = await readJson(resolve(prefix, 'package.json'))
const { name } = await readJson(prefix)
if (!name) {
throw this.usageError()
}
Loaded 100 of 321 files, more files were not shown because too many files have changed in this diff. Show more