npm-publish.1 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. .TH "NPM\-PUBLISH" "1" "October 2021" "" ""
  2. .SH "NAME"
  3. \fBnpm-publish\fR \- Publish a package
  4. .SS Synopsis
  5. .P
  6. .RS 2
  7. .nf
  8. npm publish [<tarball>|<folder>] [\-\-tag <tag>] [\-\-access <public|restricted>] [\-\-otp otpcode] [\-\-dry\-run]
  9. Publishes '\.' if no argument supplied
  10. Sets tag 'latest' if no \-\-tag specified
  11. .fi
  12. .RE
  13. .SS Description
  14. .P
  15. Publishes a package to the registry so that it can be installed by name\.
  16. .P
  17. By default npm will publish to the public registry\. This can be overridden
  18. by specifying a different default registry or using a
  19. npm help \fBscope\fP in the name (see
  20. npm help \fBpackage\.json\fP)\.
  21. .RS 0
  22. .IP \(bu 2
  23. \fB<folder>\fP: A folder containing a package\.json file
  24. .IP \(bu 2
  25. \fB<tarball>\fP: A url or file path to a gzipped tar archive containing a
  26. single folder with a package\.json file inside\.
  27. .IP \(bu 2
  28. \fB[\-\-tag <tag>]\fP: Registers the published package with the given tag, such
  29. that \fBnpm install <name>@<tag>\fP will install this version\. By default,
  30. \fBnpm publish\fP updates and \fBnpm install\fP installs the \fBlatest\fP tag\. See
  31. \fBnpm\-dist\-tag\fP \fInpm\-dist\-tag\fR for details about tags\.
  32. .IP \(bu 2
  33. \fB[\-\-access <public|restricted>]\fP: Tells the registry whether this package
  34. should be published as public or restricted\. Only applies to scoped
  35. packages, which default to \fBrestricted\fP\|\. If you don't have a paid
  36. account, you must publish with \fB\-\-access public\fP to publish scoped
  37. packages\.
  38. .IP \(bu 2
  39. \fB[\-\-otp <otpcode>]\fP: If you have two\-factor authentication enabled in
  40. \fBauth\-and\-writes\fP mode then you can provide a code from your
  41. authenticator with this\. If you don't include this and you're running
  42. from a TTY then you'll be prompted\.
  43. .IP \(bu 2
  44. \fB[\-\-dry\-run]\fP: As of \fBnpm@6\fP, does everything publish would do except
  45. actually publishing to the registry\. Reports the details of what would
  46. have been published\.
  47. .IP \(bu 2
  48. \fB[\-\-workspaces]\fP: Enables workspace context while publishing\. All
  49. workspace packages will be published\.
  50. .IP \(bu 2
  51. \fB[\-\-workspace]\fP: Enables workspaces context and limits results to only
  52. those specified by this config item\. Only the packages in the
  53. workspaces given will be published\.
  54. .RE
  55. .P
  56. The publish will fail if the package name and version combination already
  57. exists in the specified registry\.
  58. .P
  59. Once a package is published with a given name and version, that specific
  60. name and version combination can never be used again, even if it is removed
  61. with npm help \fBunpublish\fP\|\.
  62. .P
  63. As of \fBnpm@5\fP, both a sha1sum and an integrity field with a sha512sum of the
  64. tarball will be submitted to the registry during publication\. Subsequent
  65. installs will use the strongest supported algorithm to verify downloads\.
  66. .P
  67. Similar to \fB\-\-dry\-run\fP see npm help \fBpack\fP, which figures
  68. out the files to be included and packs them into a tarball to be uploaded
  69. to the registry\.
  70. .SS Files included in package
  71. .P
  72. To see what will be included in your package, run \fBnpx npm\-packlist\fP\|\. All
  73. files are included by default, with the following exceptions:
  74. .RS 0
  75. .IP \(bu 2
  76. Certain files that are relevant to package installation and distribution
  77. are always included\. For example, \fBpackage\.json\fP, \fBREADME\.md\fP,
  78. \fBLICENSE\fP, and so on\.
  79. .IP \(bu 2
  80. If there is a "files" list in
  81. npm help \fBpackage\.json\fP, then only the files
  82. specified will be included\. (If directories are specified, then they
  83. will be walked recursively and their contents included, subject to the
  84. same ignore rules\.)
  85. .IP \(bu 2
  86. If there is a \fB\|\.gitignore\fP or \fB\|\.npmignore\fP file, then ignored files in
  87. that and all child directories will be excluded from the package\. If
  88. \fIboth\fR files exist, then the \fB\|\.gitignore\fP is ignored, and only the
  89. \fB\|\.npmignore\fP is used\.
  90. \fB\|\.npmignore\fP files follow the same pattern
  91. rules \fIhttps://git\-scm\.com/book/en/v2/Git\-Basics\-Recording\-Changes\-to\-the\-Repository#_ignoring\fR
  92. as \fB\|\.gitignore\fP files
  93. .IP \(bu 2
  94. If the file matches certain patterns, then it will \fInever\fR be included,
  95. unless explicitly added to the \fB"files"\fP list in \fBpackage\.json\fP, or
  96. un\-ignored with a \fB!\fP rule in a \fB\|\.npmignore\fP or \fB\|\.gitignore\fP file\.
  97. .IP \(bu 2
  98. Symbolic links are never included in npm packages\.
  99. .RE
  100. .P
  101. See npm help \fBdevelopers\fP for full details on what's
  102. included in the published package, as well as details on how the package is
  103. built\.
  104. .SS Configuration
  105. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS START \-\->
  106. <!\-\- automatically generated, do not edit manually \-\->
  107. <!\-\- see lib/utils/config/definitions\.js \-\->
  108. .SS \fBtag\fP
  109. .RS 0
  110. .IP \(bu 2
  111. Default: "latest"
  112. .IP \(bu 2
  113. Type: String
  114. .RE
  115. .P
  116. If you ask npm to install a package and don't tell it a specific version,
  117. then it will install the specified tag\.
  118. .P
  119. Also the tag that is added to the package@version specified by the \fBnpm tag\fP
  120. command, if no explicit tag is given\.
  121. .P
  122. When used by the \fBnpm diff\fP command, this is the tag used to fetch the
  123. tarball that will be compared with the local files by default\.
  124. <!\-\- automatically generated, do not edit manually \-\->
  125. <!\-\- see lib/utils/config/definitions\.js \-\->
  126. .SS \fBaccess\fP
  127. .RS 0
  128. .IP \(bu 2
  129. Default: 'restricted' for scoped packages, 'public' for unscoped packages
  130. .IP \(bu 2
  131. Type: null, "restricted", or "public"
  132. .RE
  133. .P
  134. When publishing scoped packages, the access level defaults to \fBrestricted\fP\|\.
  135. If you want your scoped package to be publicly viewable (and installable)
  136. set \fB\-\-access=public\fP\|\. The only valid values for \fBaccess\fP are \fBpublic\fP and
  137. \fBrestricted\fP\|\. Unscoped packages \fIalways\fR have an access level of \fBpublic\fP\|\.
  138. .P
  139. Note: Using the \fB\-\-access\fP flag on the \fBnpm publish\fP command will only set
  140. the package access level on the initial publish of the package\. Any
  141. subsequent \fBnpm publish\fP commands using the \fB\-\-access\fP flag will not have an
  142. effect to the access level\. To make changes to the access level after the
  143. initial publish use \fBnpm access\fP\|\.
  144. <!\-\- automatically generated, do not edit manually \-\->
  145. <!\-\- see lib/utils/config/definitions\.js \-\->
  146. .SS \fBdry\-run\fP
  147. .RS 0
  148. .IP \(bu 2
  149. Default: false
  150. .IP \(bu 2
  151. Type: Boolean
  152. .RE
  153. .P
  154. Indicates that you don't want npm to make any changes and that it should
  155. only report what it would have done\. This can be passed into any of the
  156. commands that modify your local installation, eg, \fBinstall\fP, \fBupdate\fP,
  157. \fBdedupe\fP, \fBuninstall\fP, as well as \fBpack\fP and \fBpublish\fP\|\.
  158. .P
  159. Note: This is NOT honored by other network related commands, eg \fBdist\-tags\fP,
  160. \fBowner\fP, etc\.
  161. <!\-\- automatically generated, do not edit manually \-\->
  162. <!\-\- see lib/utils/config/definitions\.js \-\->
  163. .SS \fBotp\fP
  164. .RS 0
  165. .IP \(bu 2
  166. Default: null
  167. .IP \(bu 2
  168. Type: null or String
  169. .RE
  170. .P
  171. This is a one\-time password from a two\-factor authenticator\. It's needed
  172. when publishing or changing package permissions with \fBnpm access\fP\|\.
  173. .P
  174. If not set, and a registry response fails with a challenge for a one\-time
  175. password, npm will prompt on the command line for one\.
  176. <!\-\- automatically generated, do not edit manually \-\->
  177. <!\-\- see lib/utils/config/definitions\.js \-\->
  178. .SS \fBworkspace\fP
  179. .RS 0
  180. .IP \(bu 2
  181. Default:
  182. .IP \(bu 2
  183. Type: String (can be set multiple times)
  184. .RE
  185. .P
  186. Enable running a command in the context of the configured workspaces of the
  187. current project while filtering by running only the workspaces defined by
  188. this configuration option\.
  189. .P
  190. Valid values for the \fBworkspace\fP config are either:
  191. .RS 0
  192. .IP \(bu 2
  193. Workspace names
  194. .IP \(bu 2
  195. Path to a workspace directory
  196. .IP \(bu 2
  197. Path to a parent workspace directory (will result in selecting all
  198. workspaces within that folder)
  199. .RE
  200. .P
  201. When set for the \fBnpm init\fP command, this may be set to the folder of a
  202. workspace which does not yet exist, to create the folder and set it up as a
  203. brand new workspace within the project\.
  204. .P
  205. This value is not exported to the environment for child processes\.
  206. <!\-\- automatically generated, do not edit manually \-\->
  207. <!\-\- see lib/utils/config/definitions\.js \-\->
  208. .SS \fBworkspaces\fP
  209. .RS 0
  210. .IP \(bu 2
  211. Default: null
  212. .IP \(bu 2
  213. Type: null or Boolean
  214. .RE
  215. .P
  216. Set to true to run the command in the context of \fBall\fR configured
  217. workspaces\.
  218. .P
  219. Explicitly setting this to false will cause commands like \fBinstall\fP to
  220. ignore workspaces altogether\. When not set explicitly:
  221. .RS 0
  222. .IP \(bu 2
  223. Commands that operate on the \fBnode_modules\fP tree (install, update, etc\.)
  224. will link workspaces into the \fBnode_modules\fP folder\. \- Commands that do
  225. other things (test, exec, publish, etc\.) will operate on the root project,
  226. \fIunless\fR one or more workspaces are specified in the \fBworkspace\fP config\.
  227. .RE
  228. .P
  229. This value is not exported to the environment for child processes\.
  230. <!\-\- automatically generated, do not edit manually \-\->
  231. <!\-\- see lib/utils/config/definitions\.js \-\->
  232. .SS \fBinclude\-workspace\-root\fP
  233. .RS 0
  234. .IP \(bu 2
  235. Default: false
  236. .IP \(bu 2
  237. Type: Boolean
  238. .RE
  239. .P
  240. Include the workspace root when workspaces are enabled for a command\.
  241. .P
  242. When false, specifying individual workspaces via the \fBworkspace\fP config, or
  243. all workspaces via the \fBworkspaces\fP flag, will cause npm to operate only on
  244. the specified workspaces, and not on the root project\.
  245. <!\-\- automatically generated, do not edit manually \-\->
  246. <!\-\- see lib/utils/config/definitions\.js \-\->
  247. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS END \-\->
  248. .SS See Also
  249. .RS 0
  250. .IP \(bu 2
  251. npm\-packlist package \fIhttp://npm\.im/npm\-packlist\fR
  252. .IP \(bu 2
  253. npm help registry
  254. .IP \(bu 2
  255. npm help scope
  256. .IP \(bu 2
  257. npm help adduser
  258. .IP \(bu 2
  259. npm help owner
  260. .IP \(bu 2
  261. npm help deprecate
  262. .IP \(bu 2
  263. npm help dist\-tag
  264. .IP \(bu 2
  265. npm help pack
  266. .IP \(bu 2
  267. npm help profile
  268. .RE