1 npm-config(7) -- More than you probably want to know about npm configuration
2 ============================================================================
6 npm gets its configuration values from the following sources, sorted by priority:
10 Putting `--foo bar` on the command line sets the `foo` configuration
11 parameter to `"bar"`. A `--` argument tells the cli parser to stop
12 reading flags. A `--flag` parameter that is at the *end* of the
13 command will be given the value of `true`.
15 ### Environment Variables
17 Any environment variables that start with `npm_config_` will be
18 interpreted as a configuration parameter. For example, putting
19 `npm_config_foo=bar` in your environment will set the `foo`
20 configuration parameter to `bar`. Any environment configurations that
21 are not given a value will be given the value of `true`. Config
22 values are case-insensitive, so `NPM_CONFIG_FOO=bar` will work the
27 The four relevant files are:
29 * per-project configuration file (`/path/to/my/project/.npmrc`)
30 * per-user configuration file (defaults to `$HOME/.npmrc`; configurable via CLI
31 option `--userconfig` or environment variable `$NPM_CONF_USERCONFIG`)
32 * global configuration file (defaults to `$PREFIX/etc/npmrc`; configurable via
33 CLI option `--globalconfig` or environment variable `$NPM_CONF_GLOBALCONFIG`)
34 * npm's built-in configuration file (`/path/to/npm/npmrc`)
36 See npmrc(5) for more details.
40 A set of configuration parameters that are internal to npm, and are
41 defaults if nothing else is specified.
43 ## Shorthands and Other CLI Niceties
45 The following shorthands are parsed on the command-line:
48 * `-h`, `-?`, `--help`, `-H`: `--usage`
49 * `-s`, `--silent`: `--loglevel silent`
50 * `-q`, `--quiet`: `--loglevel warn`
51 * `-d`: `--loglevel info`
52 * `-dd`, `--verbose`: `--loglevel verbose`
53 * `-ddd`: `--loglevel silly`
58 * `-p`, `--porcelain`: `--parseable`
59 * `-reg`: `--registry`
61 * `-desc`: `--description`
64 * `-O`: `--save-optional`
65 * `-B`: `--save-bundle`
66 * `-E`: `--save-exact`
69 * `ll` and `la` commands: `ls --long`
71 If the specified configuration param resolves unambiguously to a known
72 configuration parameter, then it is expanded to that configuration
73 parameter. For example:
79 If multiple single-character shorthands are strung together, and the
80 resulting combination is unambiguously not some other configuration
81 param, then it is expanded to its various component pieces. For
86 npm ls --global --parseable --long --loglevel info
88 ## Per-Package Config Settings
90 When running scripts (see `npm-scripts(7)`) the package.json "config"
91 keys are overwritten in the environment if there is a config param of
92 `<name>[@<version>]:<key>`. For example, if the package.json has
96 , "config" : { "port" : "8080" }
97 , "scripts" : { "start" : "node server.js" } }
99 and the server.js is this:
101 http.createServer(...).listen(process.env.npm_package_config_port)
103 then the user could change the behavior by doing:
105 npm config set foo:port 80
107 See package.json(5) for more information.
113 * Default: `restricted`
116 When publishing scoped packages, the access level defaults to `restricted`. If
117 you want your scoped package to be publicly viewable (and installable) set
118 `--access=public`. The only valid values for `access` are `public` and
119 `restricted`. Unscoped packages _always_ have an access level of `public`.
126 Force npm to always require authentication when accessing the registry,
127 even for `GET` requests.
134 Tells npm to create symlinks (or `.cmd` shims on Windows) for package
137 Set to false to have it not do this. This can be used to work around
138 the fact that some file systems don't support symlinks, even on
139 ostensibly Unix systems.
143 * Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
146 The browser that is called by the `npm docs` command to open websites.
150 * Default: The npm CA certificate
151 * Type: String, Array or null
153 The Certificate Authority signing certificate that is trusted for SSL
154 connections to the registry. Values should be in PEM format with newlines
155 replaced by the string "\n". For example:
157 ca="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"
159 Set to `null` to only allow "known" registrars, or to a specific CA cert
160 to trust only that specific signing authority.
162 Multiple CAs can be trusted by specifying an array of certificates:
167 See also the `strict-ssl` config.
174 A path to a file containing one or multiple Certificate Authority signing
175 certificates. Similar to the `ca` setting, but allows for multiple CA's, as
176 well as for the CA information to be stored in a file on disk.
180 * Default: Windows: `%AppData%\npm-cache`, Posix: `~/.npm`
183 The location of npm's cache directory. See `npm-cache(1)`
187 * Default: 60000 (1 minute)
190 The number of ms before cache folder lockfiles are considered stale.
192 ### cache-lock-retries
197 Number of times to retry to acquire a lock on cache folder lockfiles.
201 * Default: 10000 (10 seconds)
204 Number of ms to wait for cache lock files to expire.
211 The maximum time (in seconds) to keep items in the registry cache before
212 re-checking against the registry.
214 Note that no purging is done unless the `npm cache clean` command is
215 explicitly used, and that only GET requests use the cache.
222 The minimum time (in seconds) to keep items in the registry cache before
223 re-checking against the registry.
225 Note that no purging is done unless the `npm cache clean` command is
226 explicitly used, and that only GET requests use the cache.
233 A client certificate to pass when accessing the registry. Values should be in
234 PEM format with newlines replaced by the string "\n". For example:
236 cert="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"
238 It is _not_ the path to a certificate file (and there is no "certfile" option).
243 * Type: Boolean or `"always"`
245 If false, never shows colors. If `"always"` then always shows colors.
246 If true, then only prints color codes for tty file descriptors.
253 The depth to go when recursing directories for `npm ls`,
254 `npm cache ls`, and `npm outdated`.
256 For `npm outdated`, a setting of `Infinity` will be treated as `0`
257 since that gives more useful information. To show the outdated status
258 of all packages and dependents, use a large integer value,
259 e.g., `npm outdated --depth 9999`
266 Show the description in `npm search`
273 Install `dev-dependencies` along with packages.
275 Note that `dev-dependencies` are also installed if the `npat` flag is
280 * Default: `EDITOR` environment variable if set, or `"vi"` on Posix,
281 or `"notepad"` on Windows.
284 The command to run for `npm edit` or `npm config edit`.
291 If set to true, then npm will stubbornly refuse to install (or even
292 consider installing) any package that claims to not be compatible with
293 the current Node.js version.
300 Makes various commands more forceful.
302 * lifecycle script failure does not block progress.
303 * publishing clobbers previously published versions.
304 * skips cache when requesting from the registry.
305 * prevents checks against clobbering non-npm files.
312 The "retries" config for the `retry` module to use when fetching
313 packages from the registry.
315 ### fetch-retry-factor
320 The "factor" config for the `retry` module to use when fetching
323 ### fetch-retry-mintimeout
325 * Default: 10000 (10 seconds)
328 The "minTimeout" config for the `retry` module to use when fetching
331 ### fetch-retry-maxtimeout
333 * Default: 60000 (1 minute)
336 The "maxTimeout" config for the `retry` module to use when fetching
344 The command to use for git commands. If git is installed on the
345 computer, but is not in the `PATH`, then set this to the full path to
353 Tag the commit when using the `npm version` command.
360 Operates in "global" mode, so that packages are installed into the
361 `prefix` folder instead of the current working directory. See
362 `npm-folders(5)` for more on the differences in behavior.
364 * packages are installed into the `{prefix}/lib/node_modules` folder, instead of the
365 current working directory.
366 * bin files are linked to `{prefix}/bin`
367 * man pages are linked to `{prefix}/share/man`
371 * Default: {prefix}/etc/npmrc
374 The config file to read for global config options.
378 * Default: GID of the current process
379 * Type: String or Number
381 The group to use when running package scripts in global mode as the root
389 The string that starts all the debugging log output.
396 A proxy to use for outgoing https requests. If the `HTTPS_PROXY` or
397 `https_proxy` or `HTTP_PROXY` or `http_proxy` environment variables are set,
398 proxy settings will be honored by the underlying `request` library.
405 If true, npm will not exit with an error code when `run-script` is invoked for
406 a script that isn't defined in the `scripts` section of `package.json`. This
407 option can be used when it's desirable to optionally run a script when it's
408 present and fail if the script fails. This is useful, for example, when running
409 scripts that may only apply for some builds in an otherwise generic CI setup.
416 If true, npm does not run scripts specified in package.json files.
420 * Default: ~/.npm-init.js
423 A module that will be loaded by the `npm init` command. See the
424 documentation for the
425 [init-package-json](https://github.com/isaacs/init-package-json) module
426 for more information, or npm-init(1).
433 The value `npm init` should use by default for the package author's name.
435 ### init-author-email
440 The value `npm init` should use by default for the package author's email.
447 The value `npm init` should use by default for the package author's homepage.
454 The value `npm init` should use by default for the package license.
461 The value that `npm init` should use by default for the package
462 version number, if not already set in package.json.
469 Whether or not to output JSON data, rather than the normal output.
471 This feature is currently experimental, and the output data structures
472 for many commands is either not implemented in JSON yet, or subject to
473 change. Only the output from `npm ls --json` is currently valid.
480 A client key to pass when accessing the registry. Values should be in PEM
481 format with newlines replaced by the string "\n". For example:
483 key="-----BEGIN PRIVATE KEY-----\nXXXX\nXXXX\n-----END PRIVATE KEY-----"
485 It is _not_ the path to a key file (and there is no "keyfile" option).
492 If true, then local installs will link if there is a suitable globally
495 Note that this means that local installs can cause things to be
496 installed into the global space at the same time. The link is only done
497 if one of the two conditions are met:
499 * The package is not already installed globally, or
500 * the globally installed version is identical to the version that is
501 being installed locally.
508 The IP address of the local interface to use when making connections
509 to the npm registry. Must be IPv4 in versions of Node prior to 0.12.
515 * Values: "silent", "error", "warn", "http", "info", "verbose", "silly"
517 What level of logs to report. On failure, *all* logs are written to
518 `npm-debug.log` in the current working directory.
520 Any logs of a higher level than the setting are shown.
521 The default is "warn", which shows warn and error output.
525 * Default: process.stderr
528 This is the stream that is passed to the
529 [npmlog](https://github.com/npm/npmlog) module at run time.
531 It cannot be set from the command line, but if you are using npm
532 programmatically, you may wish to send logs to somewhere other than
535 If the `color` config is set to true, then this stream will receive
536 colored output if it is a TTY.
543 Show extended information in `npm ls` and `npm search`.
550 The maximum number of connections to use per origin (protocol/host/port
551 combination). Passed to the `http` `Agent` used to make the request.
558 Commit message which is used by `npm version` when creating version commit.
560 Any "%s" in the message will be replaced with the version number.
564 * Default: process.version
565 * Type: semver or false
567 The node version to use when checking a package's `engines` map.
574 Run tests on installation.
581 A node module to `require()` when npm loads. Useful for programmatic
589 Attempt to install packages in the `optionalDependencies` object. Note
590 that if these packages fail to install, the overall installation
591 process is not aborted.
598 Output parseable results from commands that write to
603 * Default: see npm-folders(5)
606 The location to install global items. If set on the command line, then
607 it forces non-global commands to run in the specified folder.
614 Set to true to run in "production" mode.
616 1. devDependencies are not installed at the topmost level when running
617 local `npm install` without any arguments.
618 2. Set the NODE_ENV="production" for lifecycle scripts.
620 ### proprietary-attribs
625 Whether or not to include proprietary extended attributes in the
626 tarballs created by npm.
628 Unless you are expecting to unpack package tarballs with something other
629 than npm -- particularly a very outdated tar implementation -- leave
637 A proxy to use for outgoing http requests. If the `HTTP_PROXY` or
638 `http_proxy` environment variables are set, proxy settings will be
639 honored by the underlying `request` library.
646 Rebuild bundled dependencies after installation.
650 * Default: https://registry.npmjs.org/
653 The base URL of the npm package registry.
660 Remove failed installs.
667 Save installed packages to a package.json file as dependencies.
669 When used with the `npm rm` command, it removes it from the `dependencies`
672 Only works if there is already a package.json file present.
679 If a package would be saved at install time by the use of `--save`,
680 `--save-dev`, or `--save-optional`, then also put it in the
681 `bundleDependencies` list.
683 When used with the `npm rm` command, it removes it from the
684 bundledDependencies list.
691 Save installed packages to a package.json file as `devDependencies`.
693 When used with the `npm rm` command, it removes it from the
694 `devDependencies` object.
696 Only works if there is already a package.json file present.
703 Dependencies saved to package.json using `--save`, `--save-dev` or
704 `--save-optional` will be configured with an exact version rather than
705 using npm's default semver range operator.
712 Save installed packages to a package.json file as
713 optionalDependencies.
715 When used with the `npm rm` command, it removes it from the
716 `devDependencies` object.
718 Only works if there is already a package.json file present.
725 Configure how versions of packages installed to a package.json file via
726 `--save` or `--save-dev` get prefixed.
728 For example if a package has version `1.2.3`, by default its version is
729 set to `^1.2.3` which allows minor upgrades for that package, but after
730 `npm config set save-prefix='~'` it would be set to `~1.2.3` which only allows
738 Associate an operation with a scope for a scoped registry. Useful when logging
739 in to a private registry for the first time:
740 `npm login --scope=@organization --registry=registry.organization.com`, which
741 will cause `@organization` to be mapped to the registry for future installation
742 of packages specified according to the pattern `@organization/package`.
749 Space-separated options that are always passed to search.
756 Space-separated options that limit the results from search.
762 * Values: "name", "-name", "date", "-date", "description",
763 "-description", "keywords", "-keywords"
765 Indication of which field to sort search results by. Prefix with a `-`
766 character to indicate reverse sort.
770 * Default: SHELL environment variable, or "bash" on Posix, or "cmd" on
774 The shell to run for the `npm explore` command.
781 If set to false, then ignore `npm-shrinkwrap.json` files when
789 If set to true, then the `npm version` command will tag the version
790 using `-s` to add a signature.
792 Note that git requires you to have set up GPG keys in your git configs
793 for this to work properly.
798 * Type: Boolean or `"always"`
800 When set to `true`, npm will display an ascii spinner while it is doing
801 things, if `process.stderr` is a TTY.
803 Set to `false` to suppress the spinner, or set to `always` to output
804 the spinner even for non-TTY outputs.
811 Whether or not to do SSL key validation when making requests to the
814 See also the `ca` config.
821 If you ask npm to install a package and don't tell it a specific version, then
822 it will install the specified tag.
824 Also the tag that is added to the package@version specified by the `npm
825 tag` command, if no explicit tag is given.
827 ### tag-version-prefix
832 If set, alters the prefix used when tagging a new version when performing a
833 version increment using `npm-version`. To remove the prefix altogether, set it
834 to the empty string: `""`.
836 Because other tools may rely on the convention that npm version tags look like
837 `v1.0.0`, _only use this property if it is absolutely necessary_. In
838 particular, use care when overriding this setting for public packages.
842 * Default: TMPDIR environment variable, or "/tmp"
845 Where to store temporary files and folders. All temp files are deleted
846 on success, but left behind on failure for forensic purposes.
853 When set to true, npm uses unicode characters in the tree output. When
854 false, it uses ascii characters to draw trees.
858 * Default: false if running as root, true otherwise
861 Set to true to suppress the UID/GID switching when running package
862 scripts. If set explicitly to false, then installing as a non-root user
870 Set to show short usage output (like the -H output)
871 instead of complete help when doing `npm-help(1)`.
876 * Type: String or Number
878 The UID to set to when running package scripts as root.
885 The location of user-level configuration settings.
890 * Type: Octal numeric string in range 0000..0777 (0..511)
892 The "umask" value to use when setting the file creation mode on files
895 Folders and executables are given a mode which is `0777` masked against
896 this value. Other files are given a mode which is `0666` masked against
897 this value. Thus, the defaults are `0755` and `0644` respectively.
901 * Default: node/{process.version} {process.platform} {process.arch}
904 Sets a User-Agent to the request header
911 If true, output the npm version and exit successfully.
913 Only relevant when specified explicitly on the command line.
920 If true, output the npm version as well as node's `process.versions` map, and
923 Only relevant when specified explicitly on the command line.
927 * Default: "man" on Posix, "browser" on Windows
930 The program to use to view help content.
932 Set to `"browser"` to view html help content in the default web browser.