codekingpro/portable-devtools
114k
1<!DOCTYPE html><html><head>
2<meta charset="utf-8">
3<title>npm-publish</title>
4<style>
5body {
6 background-color: #ffffff;
7 color: #24292e;
8
9 margin: 0;
10
11 line-height: 1.5;
12
13 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
14}
15#rainbar {
16 height: 10px;
17 background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
18}
19
20a {
21 text-decoration: none;
22 color: #0366d6;
23}
24a:hover {
25 text-decoration: underline;
26}
27
28pre {
29 margin: 1em 0px;
30 padding: 1em;
31 border: solid 1px #e1e4e8;
32 border-radius: 6px;
33
34 display: block;
35 overflow: auto;
36
37 white-space: pre;
38
39 background-color: #f6f8fa;
40 color: #393a34;
41}
42code {
43 font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
44 font-size: 85%;
45 padding: 0.2em 0.4em;
46 background-color: #f6f8fa;
47 color: #393a34;
48}
49pre > code {
50 padding: 0;
51 background-color: inherit;
52 color: inherit;
53}
54h1, h2, h3 {
55 font-weight: 600;
56}
57
58#logobar {
59 background-color: #333333;
60 margin: 0 auto;
61 padding: 1em 4em;
62}
63#logobar .logo {
64 float: left;
65}
66#logobar .title {
67 font-weight: 600;
68 color: #dddddd;
69 float: left;
70 margin: 5px 0 0 1em;
71}
72#logobar:after {
73 content: "";
74 display: block;
75 clear: both;
76}
77
78#content {
79 margin: 0 auto;
80 padding: 0 4em;
81}
82
83#table_of_contents > h2 {
84 font-size: 1.17em;
85}
86#table_of_contents ul:first-child {
87 border: solid 1px #e1e4e8;
88 border-radius: 6px;
89 padding: 1em;
90 background-color: #f6f8fa;
91 color: #393a34;
92}
93#table_of_contents ul {
94 list-style-type: none;
95 padding-left: 1.5em;
96}
97#table_of_contents li {
98 font-size: 0.9em;
99}
100#table_of_contents li a {
101 color: #000000;
102}
103
104header.title {
105 border-bottom: solid 1px #e1e4e8;
106}
107header.title > h1 {
108 margin-bottom: 0.25em;
109}
110header.title > .description {
111 display: block;
112 margin-bottom: 0.5em;
113 line-height: 1;
114}
115
116header.title .version {
117 font-size: 0.8em;
118 color: #666666;
119}
120
121footer#edit {
122 border-top: solid 1px #e1e4e8;
123 margin: 3em 0 4em 0;
124 padding-top: 2em;
125}
126
127table {
128 width: 100%;
129 margin: 1em 0;
130 border-radius: 6px;
131 border: 1px solid #e1e4e8;
132 overflow: hidden;
133 border-collapse: separate;
134 border-spacing: 0;
135}
136
137table thead {
138 background-color: #f6f8fa;
139}
140
141table tbody {
142 background-color: #ffffff;
143}
144
145table th,
146table td {
147 padding: 0.75em;
148 text-align: left;
149 border-right: 1px solid #e1e4e8;
150 border-bottom: 1px solid #e1e4e8;
151}
152
153table th:last-child,
154table td:last-child {
155 border-right: none;
156}
157
158table tbody tr:last-child td {
159 border-bottom: none;
160}
161
162table th {
163 font-weight: 600;
164 background-color: #f6f8fa;
165}
166
167table code {
168 white-space: nowrap;
169}
170
171</style>
172</head>
173<body>
174<div id="banner">
175<div id="rainbar"></div>
176<div id="logobar">
177<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
178<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
179<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
180</svg>
181<div class="title">
182npm command-line interface
183</div>
184</div>
185</div>
186
187<section id="content">
188<header class="title">
189<h1 id="----npm-publish----11121">
190 <span>npm-publish</span>
191 <span class="version">@11.12.1</span>
192</h1>
193<span class="description">Publish a package</span>
194</header>
195
196<section id="table_of_contents">
197<h2 id="table-of-contents">Table of contents</h2>
198<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#examples">Examples</a></li><li><a href="#files-included-in-package">Files included in package</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#tag"><code>tag</code></a></li><li><a href="#access"><code>access</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#otp"><code>otp</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#provenance"><code>provenance</code></a></li><li><a href="#provenance-file"><code>provenance-file</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
199</section>
200
201<div id="_content"><h3 id="synopsis">Synopsis</h3>
202<pre><code class="language-bash">npm publish <package-spec>
203</code></pre>
204<h3 id="description">Description</h3>
205<p>Publishes a package to the registry so that it can be installed by name.</p>
206<h3 id="examples">Examples</h3>
207<p>Publish the package in the current directory:</p>
208<pre><code class="language-bash">npm publish
209</code></pre>
210<p>Publish a specific workspace:</p>
211<pre><code class="language-bash">npm publish --workspace=<workspace-name>
212</code></pre>
213<p>Publish multiple workspaces:</p>
214<pre><code class="language-bash">npm publish --workspace=workspace-a --workspace=workspace-b
215</code></pre>
216<p>Publish all workspaces:</p>
217<pre><code class="language-bash">npm publish --workspaces
218</code></pre>
219<p>By default npm will publish to the public registry.
220This can be overridden by specifying a different default registry or using a <a href="../using-npm/scope.html"><code>scope</code></a> in the name, combined with a scope-configured registry (see <a href="../configuring-npm/package-json.html"><code>package.json</code></a>).</p>
221<p>A <code>package</code> is interpreted the same way as other commands (like <code>npm install</code>) and can be:</p>
222<ul>
223<li>a) a folder containing a program described by a <a href="../configuring-npm/package-json.html"><code>package.json</code></a> file</li>
224<li>b) a gzipped tarball containing (a)</li>
225<li>c) a url that resolves to (b)</li>
226<li>d) a <code><name>@<version></code> that is published on the registry (see <a href="../using-npm/registry.html"><code>registry</code></a>) with (c)</li>
227<li>e) a <code><name>@<tag></code> (see <a href="../commands/npm-dist-tag.html"><code>npm dist-tag</code></a>) that points to (d)</li>
228<li>f) a <code><name></code> that has a "latest" tag satisfying (e)</li>
229<li>g) a <code><git remote url></code> that resolves to (a)</li>
230</ul>
231<p>If either (a) or (b) is specified as a relative path, it should begin with an explicit <code>./</code> prefix.</p>
232<p>The publish will fail if the package name and version combination already exists in the specified registry.</p>
233<p>Once a package is published with a given name and version, that specific name and version combination can never be used again, even if it is removed with <a href="../commands/npm-unpublish.html"><code>npm unpublish</code></a>.</p>
234<p>As of <code>npm@5</code>, both a sha1sum and an integrity field with a sha512sum of the tarball will be submitted to the registry during publication.
235Subsequent installs will use the strongest supported algorithm to verify downloads.</p>
236<p>Similar to <code>--dry-run</code> see <a href="../commands/npm-pack.html"><code>npm pack</code></a>, which figures out the files to be included and packs them into a tarball to be uploaded to the registry.</p>
237<h3 id="files-included-in-package">Files included in package</h3>
238<p>To see what will be included in your package, run <code>npm pack --dry-run</code>.
239All files are included by default, with the following exceptions:</p>
240<ul>
241<li>
242<p>Certain files that are relevant to package installation and distribution are always included.
243For example, <code>package.json</code>, <code>README.md</code>,
244<code>LICENSE</code>, and so on.</p>
245</li>
246<li>
247<p>If there is a "files" list in <a href="../configuring-npm/package-json.html"><code>package.json</code></a>, then only the files specified will be included.
248(If directories are specified, then they will be walked recursively and their contents included, subject to the same ignore rules.)</p>
249</li>
250<li>
251<p>If there is a <code>.gitignore</code> or <code>.npmignore</code> file, then ignored files in that and all child directories will be excluded from the package.
252If <em>both</em> files exist, then the <code>.gitignore</code> is ignored, and only the
253<code>.npmignore</code> is used.</p>
254<p><code>.npmignore</code> files follow the <a href="https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring">same pattern rules</a> as <code>.gitignore</code> files</p>
255</li>
256<li>
257<p>If the file matches certain patterns, then it will <em>never</em> be included, unless explicitly added to the <code>"files"</code> list in <code>package.json</code>, or un-ignored with a <code>!</code> rule in a <code>.npmignore</code> or <code>.gitignore</code> file.</p>
258</li>
259<li>
260<p>Symbolic links are never included in npm packages.</p>
261</li>
262</ul>
263<p>See <a href="../using-npm/developers.html"><code>developers</code></a> for full details on what's included in the published package, as well as details on how the package is built.</p>
264<p>See <a href="../configuring-npm/package-json.html"><code>package.json</code></a> for more info on what can and can't be ignored.</p>
265<h3 id="configuration">Configuration</h3>
266<h4 id="tag"><code>tag</code></h4>
267<ul>
268<li>Default: "latest"</li>
269<li>Type: String</li>
270</ul>
271<p>If you ask npm to install a package and don't tell it a specific version,
272then it will install the specified tag.</p>
273<p>It is the tag added to the package@version specified in the <code>npm dist-tag add</code> command, if no explicit tag is given.</p>
274<p>When used by the <code>npm diff</code> command, this is the tag used to fetch the
275tarball that will be compared with the local files by default.</p>
276<p>If used in the <code>npm publish</code> command, this is the tag that will be added to
277the package submitted to the registry.</p>
278<h4 id="access"><code>access</code></h4>
279<ul>
280<li>Default: 'public' for new packages, existing packages it will not change the
281current level</li>
282<li>Type: null, "restricted", or "public"</li>
283</ul>
284<p>If you do not want your scoped package to be publicly viewable (and
285installable) set <code>--access=restricted</code>.</p>
286<p>Unscoped packages cannot be set to <code>restricted</code>.</p>
287<p>Note: This defaults to not changing the current access level for existing
288packages. Specifying a value of <code>restricted</code> or <code>public</code> during publish will
289change the access for an existing package the same way that <code>npm access set status</code> would.</p>
290<h4 id="dry-run"><code>dry-run</code></h4>
291<ul>
292<li>Default: false</li>
293<li>Type: Boolean</li>
294</ul>
295<p>Indicates that you don't want npm to make any changes and that it should
296only report what it would have done. This can be passed into any of the
297commands that modify your local installation, eg, <code>install</code>, <code>update</code>,
298<code>dedupe</code>, <code>uninstall</code>, as well as <code>pack</code> and <code>publish</code>.</p>
299<p>Note: This is NOT honored by other network related commands, eg <code>dist-tags</code>,
300<code>owner</code>, etc.</p>
301<h4 id="otp"><code>otp</code></h4>
302<ul>
303<li>Default: null</li>
304<li>Type: null or String</li>
305</ul>
306<p>This is a one-time password from a two-factor authenticator. It's needed
307when publishing or changing package permissions with <code>npm access</code>.</p>
308<p>If not set, and a registry response fails with a challenge for a one-time
309password, npm will prompt on the command line for one.</p>
310<h4 id="workspace"><code>workspace</code></h4>
311<ul>
312<li>Default:</li>
313<li>Type: String (can be set multiple times)</li>
314</ul>
315<p>Enable running a command in the context of the configured workspaces of the
316current project while filtering by running only the workspaces defined by
317this configuration option.</p>
318<p>Valid values for the <code>workspace</code> config are either:</p>
319<ul>
320<li>Workspace names</li>
321<li>Path to a workspace directory</li>
322<li>Path to a parent workspace directory (will result in selecting all
323workspaces within that folder)</li>
324</ul>
325<p>When set for the <code>npm init</code> command, this may be set to the folder of a
326workspace which does not yet exist, to create the folder and set it up as a
327brand new workspace within the project.</p>
328<p>This value is not exported to the environment for child processes.</p>
329<h4 id="workspaces"><code>workspaces</code></h4>
330<ul>
331<li>Default: null</li>
332<li>Type: null or Boolean</li>
333</ul>
334<p>Set to true to run the command in the context of <strong>all</strong> configured
335workspaces.</p>
336<p>Explicitly setting this to false will cause commands like <code>install</code> to
337ignore workspaces altogether. When not set explicitly:</p>
338<ul>
339<li>Commands that operate on the <code>node_modules</code> tree (install, update, etc.)
340will link workspaces into the <code>node_modules</code> folder. - Commands that do
341other things (test, exec, publish, etc.) will operate on the root project,
342<em>unless</em> one or more workspaces are specified in the <code>workspace</code> config.</li>
343</ul>
344<p>This value is not exported to the environment for child processes.</p>
345<h4 id="include-workspace-root"><code>include-workspace-root</code></h4>
346<ul>
347<li>Default: false</li>
348<li>Type: Boolean</li>
349</ul>
350<p>Include the workspace root when workspaces are enabled for a command.</p>
351<p>When false, specifying individual workspaces via the <code>workspace</code> config, or
352all workspaces via the <code>workspaces</code> flag, will cause npm to operate only on
353the specified workspaces, and not on the root project.</p>
354<p>This value is not exported to the environment for child processes.</p>
355<h4 id="provenance"><code>provenance</code></h4>
356<ul>
357<li>Default: false</li>
358<li>Type: Boolean</li>
359</ul>
360<p>When publishing from a supported cloud CI/CD system, the package will be
361publicly linked to where it was built and published from.</p>
362<p>This config cannot be used with: <code>provenance-file</code></p>
363<h4 id="provenance-file"><code>provenance-file</code></h4>
364<ul>
365<li>Default: null</li>
366<li>Type: Path</li>
367</ul>
368<p>When publishing, the provenance bundle at the given path will be used.</p>
369<p>This config cannot be used with: <code>provenance</code></p>
370<h3 id="see-also">See Also</h3>
371<ul>
372<li><a href="../using-npm/package-spec.html">package spec</a></li>
373<li><a href="http://npm.im/npm-packlist">npm-packlist package</a></li>
374<li><a href="../using-npm/registry.html">npm registry</a></li>
375<li><a href="../using-npm/scope.html">npm scope</a></li>
376<li><a href="../commands/npm-adduser.html">npm adduser</a></li>
377<li><a href="../commands/npm-owner.html">npm owner</a></li>
378<li><a href="../commands/npm-deprecate.html">npm deprecate</a></li>
379<li><a href="../commands/npm-dist-tag.html">npm dist-tag</a></li>
380<li><a href="../commands/npm-pack.html">npm pack</a></li>
381<li><a href="../commands/npm-profile.html">npm profile</a></li>
382</ul></div>
383
384<footer id="edit">
385<a href="https://github.com/npm/cli/edit/latest/docs/lib/content/commands/npm-publish.md">
386<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
387<path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path>
388</svg>
389Edit this page on GitHub
390</a>
391</footer>
392</section>
393
394
395
396</body></html>