npmrc.5 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. .TH "NPMRC" "5" "September 2021" "" ""
  2. .SH "NAME"
  3. \fBnpmrc\fR \- The npm config files
  4. .SS Description
  5. .P
  6. npm gets its config settings from the command line, environment variables,
  7. and \fBnpmrc\fP files\.
  8. .P
  9. The \fBnpm config\fP command can be used to update and edit the contents of the
  10. user and global npmrc files\.
  11. .P
  12. For a list of available configuration options, see
  13. npm help config\.
  14. .SS Files
  15. .P
  16. The four relevant files are:
  17. .RS 0
  18. .IP \(bu 2
  19. per\-project config file (/path/to/my/project/\.npmrc)
  20. .IP \(bu 2
  21. per\-user config file (~/\.npmrc)
  22. .IP \(bu 2
  23. global config file ($PREFIX/etc/npmrc)
  24. .IP \(bu 2
  25. npm builtin config file (/path/to/npm/npmrc)
  26. .RE
  27. .P
  28. All npm config files are an ini\-formatted list of \fBkey = value\fP parameters\.
  29. Environment variables can be replaced using \fB${VARIABLE_NAME}\fP\|\. For
  30. example:
  31. .P
  32. .RS 2
  33. .nf
  34. prefix = ${HOME}/\.npm\-packages
  35. .fi
  36. .RE
  37. .P
  38. Each of these files is loaded, and config options are resolved in priority
  39. order\. For example, a setting in the userconfig file would override the
  40. setting in the globalconfig file\.
  41. .P
  42. Array values are specified by adding "[]" after the key name\. For example:
  43. .P
  44. .RS 2
  45. .nf
  46. key[] = "first value"
  47. key[] = "second value"
  48. .fi
  49. .RE
  50. .SS Comments
  51. .P
  52. Lines in \fB\|\.npmrc\fP files are interpreted as comments when they begin with a
  53. \fB;\fP or \fB#\fP character\. \fB\|\.npmrc\fP files are parsed by
  54. npm/ini \fIhttps://github\.com/npm/ini\fR, which specifies this comment syntax\.
  55. .P
  56. For example:
  57. .P
  58. .RS 2
  59. .nf
  60. # last modified: 01 Jan 2016
  61. ; Set a new registry for a scoped package
  62. @myscope:registry=https://mycustomregistry\.example\.org
  63. .fi
  64. .RE
  65. .SS Per\-project config file
  66. .P
  67. When working locally in a project, a \fB\|\.npmrc\fP file in the root of the
  68. project (ie, a sibling of \fBnode_modules\fP and \fBpackage\.json\fP) will set
  69. config values specific to this project\.
  70. .P
  71. Note that this only applies to the root of the project that you're running
  72. npm in\. It has no effect when your module is published\. For example, you
  73. can't publish a module that forces itself to install globally, or in a
  74. different location\.
  75. .P
  76. Additionally, this file is not read in global mode, such as when running
  77. \fBnpm install \-g\fP\|\.
  78. .SS Per\-user config file
  79. .P
  80. \fB$HOME/\.npmrc\fP (or the \fBuserconfig\fP param, if set in the environment or on
  81. the command line)
  82. .SS Global config file
  83. .P
  84. \fB$PREFIX/etc/npmrc\fP (or the \fBglobalconfig\fP param, if set above): This file
  85. is an ini\-file formatted list of \fBkey = value\fP parameters\. Environment
  86. variables can be replaced as above\.
  87. .SS Built\-in config file
  88. .P
  89. \fBpath/to/npm/itself/npmrc\fP
  90. .P
  91. This is an unchangeable "builtin" configuration file that npm keeps
  92. consistent across updates\. Set fields in here using the \fB\|\./configure\fP
  93. script that comes with npm\. This is primarily for distribution maintainers
  94. to override default configs in a standard and consistent manner\.
  95. .SS See also
  96. .RS 0
  97. .IP \(bu 2
  98. npm help folders
  99. .IP \(bu 2
  100. npm help config
  101. .IP \(bu 2
  102. npm help config
  103. .IP \(bu 2
  104. npm help package\.json
  105. .IP \(bu 2
  106. npm help npm
  107. .RE