npmrc.5 3.0 KB

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