750b80972c2e4a2a69c4f26e39dae9d1bae370fa
[platform/upstream/nodejs.git] / deps / npm / doc / misc / npm-config.md
1 npm-config(7) -- More than you probably want to know about npm configuration
2 ============================================================================
3
4 ## DESCRIPTION
5
6 npm gets its configuration values from 6 sources, in this priority:
7
8 ### Command Line Flags
9
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`.
14
15 ### Environment Variables
16
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
23 same.
24
25 ### npmrc Files
26
27 The three relevant files are:
28
29 * per-user config file (~/.npmrc)
30 * global config file ($PREFIX/npmrc)
31 * npm builtin config file (/path/to/npm/npmrc)
32
33 See npmrc(5) for more details.
34
35 ### Default Configs
36
37 A set of configuration parameters that are internal to npm, and are
38 defaults if nothing else is specified.
39
40 ## Shorthands and Other CLI Niceties
41
42 The following shorthands are parsed on the command-line:
43
44 * `-v`: `--version`
45 * `-h`, `-?`, `--help`, `-H`: `--usage`
46 * `-s`, `--silent`: `--loglevel silent`
47 * `-q`, `--quiet`: `--loglevel warn`
48 * `-d`: `--loglevel info`
49 * `-dd`, `--verbose`: `--loglevel verbose`
50 * `-ddd`: `--loglevel silly`
51 * `-g`: `--global`
52 * `-l`: `--long`
53 * `-m`: `--message`
54 * `-p`, `--porcelain`: `--parseable`
55 * `-reg`: `--registry`
56 * `-v`: `--version`
57 * `-f`: `--force`
58 * `-desc`: `--description`
59 * `-S`: `--save`
60 * `-D`: `--save-dev`
61 * `-O`: `--save-optional`
62 * `-B`: `--save-bundle`
63 * `-y`: `--yes`
64 * `-n`: `--yes false`
65 * `ll` and `la` commands: `ls --long`
66
67 If the specified configuration param resolves unambiguously to a known
68 configuration parameter, then it is expanded to that configuration
69 parameter.  For example:
70
71     npm ls --par
72     # same as:
73     npm ls --parseable
74
75 If multiple single-character shorthands are strung together, and the
76 resulting combination is unambiguously not some other configuration
77 param, then it is expanded to its various component pieces.  For
78 example:
79
80     npm ls -gpld
81     # same as:
82     npm ls --global --parseable --long --loglevel info
83
84 ## Per-Package Config Settings
85
86 When running scripts (see `npm-scripts(7)`) the package.json "config"
87 keys are overwritten in the environment if there is a config param of
88 `<name>[@<version>]:<key>`.  For example, if the package.json has
89 this:
90
91     { "name" : "foo"
92     , "config" : { "port" : "8080" }
93     , "scripts" : { "start" : "node server.js" } }
94
95 and the server.js is this:
96
97     http.createServer(...).listen(process.env.npm_package_config_port)
98
99 then the user could change the behavior by doing:
100
101     npm config set foo:port 80
102
103 See package.json(5) for more information.
104
105 ## Config Settings
106
107 ### always-auth
108
109 * Default: false
110 * Type: Boolean
111
112 Force npm to always require authentication when accessing the registry,
113 even for `GET` requests.
114
115 ### bin-links
116
117 * Default: `true`
118 * Type: Boolean
119
120 Tells npm to create symlinks (or `.cmd` shims on Windows) for package
121 executables.
122
123 Set to false to have it not do this.  This can be used to work around
124 the fact that some file systems don't support symlinks, even on
125 ostensibly Unix systems.
126
127 ### browser
128
129 * Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
130 * Type: String
131
132 The browser that is called by the `npm docs` command to open websites.
133
134 ### ca
135
136 * Default: The npm CA certificate
137 * Type: String or null
138
139 The Certificate Authority signing certificate that is trusted for SSL
140 connections to the registry.
141
142 Set to `null` to only allow "known" registrars, or to a specific CA cert
143 to trust only that specific signing authority.
144
145 See also the `strict-ssl` config.
146
147 ### cache
148
149 * Default: Windows: `%AppData%\npm-cache`, Posix: `~/.npm`
150 * Type: path
151
152 The location of npm's cache directory.  See `npm-cache(1)`
153
154 ### cache-lock-stale
155
156 * Default: 60000 (1 minute)
157 * Type: Number
158
159 The number of ms before cache folder lockfiles are considered stale.
160
161 ### cache-lock-retries
162
163 * Default: 10
164 * Type: Number
165
166 Number of times to retry to acquire a lock on cache folder lockfiles.
167
168 ### cache-lock-wait
169
170 * Default: 10000 (10 seconds)
171 * Type: Number
172
173 Number of ms to wait for cache lock files to expire.
174
175 ### cache-max
176
177 * Default: Infinity
178 * Type: Number
179
180 The maximum time (in seconds) to keep items in the registry cache before
181 re-checking against the registry.
182
183 Note that no purging is done unless the `npm cache clean` command is
184 explicitly used, and that only GET requests use the cache.
185
186 ### cache-min
187
188 * Default: 10
189 * Type: Number
190
191 The minimum time (in seconds) to keep items in the registry cache before
192 re-checking against the registry.
193
194 Note that no purging is done unless the `npm cache clean` command is
195 explicitly used, and that only GET requests use the cache.
196
197 ### color
198
199 * Default: true on Posix, false on Windows
200 * Type: Boolean or `"always"`
201
202 If false, never shows colors.  If `"always"` then always shows colors.
203 If true, then only prints color codes for tty file descriptors.
204
205 ### coverage
206
207 * Default: false
208 * Type: Boolean
209
210 A flag to tell test-harness to run with their coverage options enabled,
211 if they respond to the `npm_config_coverage` environment variable.
212
213 ### depth
214
215 * Default: Infinity
216 * Type: Number
217
218 The depth to go when recursing directories for `npm ls` and
219 `npm cache ls`.
220
221 ### description
222
223 * Default: true
224 * Type: Boolean
225
226 Show the description in `npm search`
227
228 ### dev
229
230 * Default: false
231 * Type: Boolean
232
233 Install `dev-dependencies` along with packages.
234
235 Note that `dev-dependencies` are also installed if the `npat` flag is
236 set.
237
238 ### editor
239
240 * Default: `EDITOR` environment variable if set, or `"vi"` on Posix,
241   or `"notepad"` on Windows.
242 * Type: path
243
244 The command to run for `npm edit` or `npm config edit`.
245
246 ### engine-strict
247
248 * Default: false
249 * Type: Boolean
250
251 If set to true, then npm will stubbornly refuse to install (or even
252 consider installing) any package that claims to not be compatible with
253 the current Node.js version.
254
255 ### force
256
257 * Default: false
258 * Type: Boolean
259
260 Makes various commands more forceful.
261
262 * lifecycle script failure does not block progress.
263 * publishing clobbers previously published versions.
264 * skips cache when requesting from the registry.
265 * prevents checks against clobbering non-npm files.
266
267 ### fetch-retries
268
269 * Default: 2
270 * Type: Number
271
272 The "retries" config for the `retry` module to use when fetching
273 packages from the registry.
274
275 ### fetch-retry-factor
276
277 * Default: 10
278 * Type: Number
279
280 The "factor" config for the `retry` module to use when fetching
281 packages.
282
283 ### fetch-retry-mintimeout
284
285 * Default: 10000 (10 seconds)
286 * Type: Number
287
288 The "minTimeout" config for the `retry` module to use when fetching
289 packages.
290
291 ### fetch-retry-maxtimeout
292
293 * Default: 60000 (1 minute)
294 * Type: Number
295
296 The "maxTimeout" config for the `retry` module to use when fetching
297 packages.
298
299 ### git
300
301 * Default: `"git"`
302 * Type: String
303
304 The command to use for git commands.  If git is installed on the
305 computer, but is not in the `PATH`, then set this to the full path to
306 the git binary.
307
308 ### global
309
310 * Default: false
311 * Type: Boolean
312
313 Operates in "global" mode, so that packages are installed into the
314 `prefix` folder instead of the current working directory.  See
315 `npm-folders(5)` for more on the differences in behavior.
316
317 * packages are installed into the `{prefix}/lib/node_modules` folder, instead of the
318   current working directory.
319 * bin files are linked to `{prefix}/bin`
320 * man pages are linked to `{prefix}/share/man`
321
322 ### globalconfig
323
324 * Default: {prefix}/etc/npmrc
325 * Type: path
326
327 The config file to read for global config options.
328
329 ### globalignorefile
330
331 * Default: {prefix}/etc/npmignore
332 * Type: path
333
334 The config file to read for global ignore patterns to apply to all users
335 and all projects.
336
337 If not found, but there is a "gitignore" file in the
338 same directory, then that will be used instead.
339
340 ### group
341
342 * Default: GID of the current process
343 * Type: String or Number
344
345 The group to use when running package scripts in global mode as the root
346 user.
347
348 ### https-proxy
349
350 * Default: the `HTTPS_PROXY` or `https_proxy` or `HTTP_PROXY` or
351   `http_proxy` environment variables.
352 * Type: url
353
354 A proxy to use for outgoing https requests.
355
356 ### user-agent
357
358 * Default: node/{process.version} {process.platform} {process.arch}
359 * Type: String
360
361 Sets a User-Agent to the request header
362
363 ### ignore
364
365 * Default: ""
366 * Type: string
367
368 A white-space separated list of glob patterns of files to always exclude
369 from packages when building tarballs.
370
371 ### init-module
372
373 * Default: ~/.npm-init.js
374 * Type: path
375
376 A module that will be loaded by the `npm init` command.  See the
377 documentation for the
378 [init-package-json](https://github.com/isaacs/init-package-json) module
379 for more information, or npm-init(1).
380
381 ### init.version
382
383 * Default: "0.0.0"
384 * Type: semver
385
386 The value `npm init` should use by default for the package version.
387
388 ### init.author.name
389
390 * Default: ""
391 * Type: String
392
393 The value `npm init` should use by default for the package author's name.
394
395 ### init.author.email
396
397 * Default: ""
398 * Type: String
399
400 The value `npm init` should use by default for the package author's email.
401
402 ### init.author.url
403
404 * Default: ""
405 * Type: String
406
407 The value `npm init` should use by default for the package author's homepage.
408
409 ### json
410
411 * Default: false
412 * Type: Boolean
413
414 Whether or not to output JSON data, rather than the normal output.
415
416 This feature is currently experimental, and the output data structures
417 for many commands is either not implemented in JSON yet, or subject to
418 change.  Only the output from `npm ls --json` is currently valid.
419
420 ### link
421
422 * Default: false
423 * Type: Boolean
424
425 If true, then local installs will link if there is a suitable globally
426 installed package.
427
428 Note that this means that local installs can cause things to be
429 installed into the global space at the same time.  The link is only done
430 if one of the two conditions are met:
431
432 * The package is not already installed globally, or
433 * the globally installed version is identical to the version that is
434   being installed locally.
435
436 ### loglevel
437
438 * Default: "http"
439 * Type: String
440 * Values: "silent", "win", "error", "warn", "http", "info", "verbose", "silly"
441
442 What level of logs to report.  On failure, *all* logs are written to
443 `npm-debug.log` in the current working directory.
444
445 Any logs of a higher level than the setting are shown.
446 The default is "http", which shows http, warn, and error output.
447
448 ### logstream
449
450 * Default: process.stderr
451 * Type: Stream
452
453 This is the stream that is passed to the
454 [npmlog](https://github.com/isaacs/npmlog) module at run time.
455
456 It cannot be set from the command line, but if you are using npm
457 programmatically, you may wish to send logs to somewhere other than
458 stderr.
459
460 If the `color` config is set to true, then this stream will receive
461 colored output if it is a TTY.
462
463 ### long
464
465 * Default: false
466 * Type: Boolean
467
468 Show extended information in `npm ls`
469
470 ### message
471
472 * Default: "%s"
473 * Type: String
474
475 Commit message which is used by `npm version` when creating version commit.
476
477 Any "%s" in the message will be replaced with the version number.
478
479 ### node-version
480
481 * Default: process.version
482 * Type: semver or false
483
484 The node version to use when checking package's "engines" hash.
485
486 ### npat
487
488 * Default: false
489 * Type: Boolean
490
491 Run tests on installation and report results to the
492 `npaturl`.
493
494 ### npaturl
495
496 * Default: Not yet implemented
497 * Type: url
498
499 The url to report npat test results.
500
501 ### onload-script
502
503 * Default: false
504 * Type: path
505
506 A node module to `require()` when npm loads.  Useful for programmatic
507 usage.
508
509 ### optional
510
511 * Default: true
512 * Type: Boolean
513
514 Attempt to install packages in the `optionalDependencies` hash.  Note
515 that if these packages fail to install, the overall installation
516 process is not aborted.
517
518 ### parseable
519
520 * Default: false
521 * Type: Boolean
522
523 Output parseable results from commands that write to
524 standard output.
525
526 ### prefix
527
528 * Default: see npm-folders(5)
529 * Type: path
530
531 The location to install global items.  If set on the command line, then
532 it forces non-global commands to run in the specified folder.
533
534 ### production
535
536 * Default: false
537 * Type: Boolean
538
539 Set to true to run in "production" mode.
540
541 1. devDependencies are not installed at the topmost level when running
542    local `npm install` without any arguments.
543 2. Set the NODE_ENV="production" for lifecycle scripts.
544
545 ### proprietary-attribs
546
547 * Default: true
548 * Type: Boolean
549
550 Whether or not to include proprietary extended attributes in the
551 tarballs created by npm.
552
553 Unless you are expecting to unpack package tarballs with something other
554 than npm -- particularly a very outdated tar implementation -- leave
555 this as true.
556
557 ### proxy
558
559 * Default: `HTTP_PROXY` or `http_proxy` environment variable, or null
560 * Type: url
561
562 A proxy to use for outgoing http requests.
563
564 ### rebuild-bundle
565
566 * Default: true
567 * Type: Boolean
568
569 Rebuild bundled dependencies after installation.
570
571 ### registry
572
573 * Default: https://registry.npmjs.org/
574 * Type: url
575
576 The base URL of the npm package registry.
577
578 ### rollback
579
580 * Default: true
581 * Type: Boolean
582
583 Remove failed installs.
584
585 ### save
586
587 * Default: false
588 * Type: Boolean
589
590 Save installed packages to a package.json file as dependencies.
591
592 When used with the `npm rm` command, it removes it from the dependencies
593 hash.
594
595 Only works if there is already a package.json file present.
596
597 ### save-bundle
598
599 * Default: false
600 * Type: Boolean
601
602 If a package would be saved at install time by the use of `--save`,
603 `--save-dev`, or `--save-optional`, then also put it in the
604 `bundleDependencies` list.
605
606 When used with the `npm rm` command, it removes it from the
607 bundledDependencies list.
608
609 ### save-dev
610
611 * Default: false
612 * Type: Boolean
613
614 Save installed packages to a package.json file as devDependencies.
615
616 When used with the `npm rm` command, it removes it from the devDependencies
617 hash.
618
619 Only works if there is already a package.json file present.
620
621 ### save-optional
622
623 * Default: false
624 * Type: Boolean
625
626 Save installed packages to a package.json file as optionalDependencies.
627
628 When used with the `npm rm` command, it removes it from the devDependencies
629 hash.
630
631 Only works if there is already a package.json file present.
632
633 ### searchopts
634
635 * Default: ""
636 * Type: String
637
638 Space-separated options that are always passed to search.
639
640 ### searchexclude
641
642 * Default: ""
643 * Type: String
644
645 Space-separated options that limit the results from search.
646
647 ### searchsort
648
649 * Default: "name"
650 * Type: String
651 * Values: "name", "-name", "date", "-date", "description",
652   "-description", "keywords", "-keywords"
653
654 Indication of which field to sort search results by.  Prefix with a `-`
655 character to indicate reverse sort.
656
657 ### shell
658
659 * Default: SHELL environment variable, or "bash" on Posix, or "cmd" on
660   Windows
661 * Type: path
662
663 The shell to run for the `npm explore` command.
664
665 ### shrinkwrap
666
667 * Default: true
668 * Type: Boolean
669
670 If set to false, then ignore `npm-shrinkwrap.json` files when
671 installing.
672
673 ### sign-git-tag
674
675 * Default: false
676 * Type: Boolean
677
678 If set to true, then the `npm version` command will tag the version
679 using `-s` to add a signature.
680
681 Note that git requires you to have set up GPG keys in your git configs
682 for this to work properly.
683
684 ### strict-ssl
685
686 * Default: true
687 * Type: Boolean
688
689 Whether or not to do SSL key validation when making requests to the
690 registry via https.
691
692 See also the `ca` config.
693
694 ### tag
695
696 * Default: latest
697 * Type: String
698
699 If you ask npm to install a package and don't tell it a specific version, then
700 it will install the specified tag.
701
702 Also the tag that is added to the package@version specified by the `npm
703 tag` command, if no explicit tag is given.
704
705 ### tmp
706
707 * Default: TMPDIR environment variable, or "/tmp"
708 * Type: path
709
710 Where to store temporary files and folders.  All temp files are deleted
711 on success, but left behind on failure for forensic purposes.
712
713 ### unicode
714
715 * Default: true
716 * Type: Boolean
717
718 When set to true, npm uses unicode characters in the tree output.  When
719 false, it uses ascii characters to draw trees.
720
721 ### unsafe-perm
722
723 * Default: false if running as root, true otherwise
724 * Type: Boolean
725
726 Set to true to suppress the UID/GID switching when running package
727 scripts.  If set explicitly to false, then installing as a non-root user
728 will fail.
729
730 ### usage
731
732 * Default: false
733 * Type: Boolean
734
735 Set to show short usage output (like the -H output)
736 instead of complete help when doing `npm-help(1)`.
737
738 ### user
739
740 * Default: "nobody"
741 * Type: String or Number
742
743 The UID to set to when running package scripts as root.
744
745 ### username
746
747 * Default: null
748 * Type: String
749
750 The username on the npm registry.  Set with `npm adduser`
751
752 ### userconfig
753
754 * Default: ~/.npmrc
755 * Type: path
756
757 The location of user-level configuration settings.
758
759 ### userignorefile
760
761 * Default: ~/.npmignore
762 * Type: path
763
764 The location of a user-level ignore file to apply to all packages.
765
766 If not found, but there is a .gitignore file in the same directory, then
767 that will be used instead.
768
769 ### umask
770
771 * Default: 022
772 * Type: Octal numeric string
773
774 The "umask" value to use when setting the file creation mode on files
775 and folders.
776
777 Folders and executables are given a mode which is `0777` masked against
778 this value.  Other files are given a mode which is `0666` masked against
779 this value.  Thus, the defaults are `0755` and `0644` respectively.
780
781 ### version
782
783 * Default: false
784 * Type: boolean
785
786 If true, output the npm version and exit successfully.
787
788 Only relevant when specified explicitly on the command line.
789
790 ### versions
791
792 * Default: false
793 * Type: boolean
794
795 If true, output the npm version as well as node's `process.versions`
796 hash, and exit successfully.
797
798 Only relevant when specified explicitly on the command line.
799
800 ### viewer
801
802 * Default: "man" on Posix, "browser" on Windows
803 * Type: path
804
805 The program to use to view help content.
806
807 Set to `"browser"` to view html help content in the default web browser.
808
809 ### yes
810
811 * Default: null
812 * Type: Boolean or null
813
814 If set to `null`, then prompt the user for responses in some
815 circumstances.
816
817 If set to `true`, then answer "yes" to any prompt.  If set to `false`
818 then answer "no" to any prompt.
819
820 ## SEE ALSO
821
822 * npm-config(1)
823 * npm-config(7)
824 * npmrc(5)
825 * npm-scripts(7)
826 * npm-folders(5)
827 * npm(1)