From e658b9f04b8e5a49091adc4ea0b3625ccebd1f05 Mon Sep 17 00:00:00 2001 From: Max Black Date: Sat, 29 Nov 2025 17:21:11 -0800 Subject: [PATCH] docs: add examples for command line flags including --prefix --- docs/lib/content/using-npm/config.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/lib/content/using-npm/config.md b/docs/lib/content/using-npm/config.md index c1e117a807e31..252bbcf3a27e2 100644 --- a/docs/lib/content/using-npm/config.md +++ b/docs/lib/content/using-npm/config.md @@ -20,6 +20,14 @@ Using `--flag` without specifying any value will set the value to `true`. 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. +**Common examples:** + +* `npm install --prefix /path/to/dir` - Runs npm commands in a different directory without changing the current working directory +* `npm install --global` - Installs packages globally (shorthand: `-g`) +* `npm install --save-dev` - Saves to devDependencies (shorthand: `-D`) + +Any configuration option documented in the [Config Settings](#config-settings) section below can be set via command line flags using `--option-name value` syntax. + #### Environment Variables Any environment variables that start with `npm_config_` will be interpreted as a configuration parameter.