Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions content/cli/v11/using-npm/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,21 @@ npm gets its configuration values from the following sources, sorted by priority

#### Command Line Flags

Putting `--foo bar` on the command line sets the `foo` configuration parameter to `"bar"`. A `--` argument tells the cli parser to stop reading flags. Using `--flag` without specifying any value will set the value to `true`.
A flag, also known as a switch or command-line option, is a parameter provided to the CLI to act upon.

Example: `--flag1 --flag2` will set both configuration parameters to `true`, while `--flag1 --flag2 bar` will set `flag1` to `true`, and `flag2` to `bar`. Finally, `--flag1 --flag2 -- bar` will set both configuration parameters to `true`, and the `bar` is taken as a command argument.
_**Note:** In this document `foo` and `bar` are used as placeholders to represent generic examples of parameter names and values. They are not literal parameters._

Using `--` by itself tells the CLI parser to stop interpreting further arguments (such as `foo`) as flags.

Instead, using `--foo` without any further value will set the value of `foo` to `true`.

Alternatively, using `--foo bar` with `bar` as the supplied value will set the value of `--foo` to `bar`.

**Example:**

- Using `--flag1 --flag2` will set both configuration parameters `flag1` and `flag2` to `true` as no further value is provided for either.
- Using `--flag1 --flag2 bar` will set the value of `flag1` to `true`, and the value of `flag2` to `bar`.
- Using `--flag1 --flag2 -- bar` will set the values of both `flag1` and `flag2` to `true`, while `bar` is treated as a regular command argument.

#### Environment Variables

Expand Down