1NPM-PUBLISH(1)                                                  NPM-PUBLISH(1)
2
3
4

NAME

6       npm-publish - Publish a package
7
8   Synopsis
9         npm publish <package-spec>
10
11   Description
12       Publishes  a  package  to  the  registry so that it can be installed by
13       name.
14
15       By default npm will publish to the public registry. This can  be  over‐
16       ridden  by  specifying a different default registry or using a npm help
17       scope in the name, combined with a scope-configured registry  (see  npm
18       help package.json).
19
20       A  package  is interpreted the same way as other commands (like npm in‐
21       stall and can be:
22
23       • a) a folder containing a program described by a npm help package.json
24         file
25
26       • b) a gzipped tarball containing (a)
27
28       • c) a url that resolves to (b)
29
30       • d) a <name>@<version> that is published on the registry (see npm help
31         registry) with (c)
32
33       • e) a <name>@<tag> (see npm help dist-tag) that points to (d)
34
35       • f) a <name> that has a "latest" tag satisfying (e)
36
37       • g) a <git remote url> that resolves to (a)
38
39
40       The publish will fail if the package name and version  combination  al‐
41       ready exists in the specified registry.
42
43       Once  a  package  is published with a given name and version, that spe‐
44       cific name and version combination can never be used again, even if  it
45       is removed with npm help unpublish.
46
47       As  of npm@5, both a sha1sum and an integrity field with a sha512sum of
48       the tarball will be submitted to the registry during publication.  Sub‐
49       sequent  installs  will use the strongest supported algorithm to verify
50       downloads.
51
52       Similar to --dry-run see npm help pack, which figures out the files  to
53       be  included  and  packs them into a tarball to be uploaded to the reg‐
54       istry.
55
56   Files included in package
57       To see what will be included in your  package,  run  npx  npm-packlist.
58       All files are included by default, with the following exceptions:
59
60       • Certain files that are relevant to package installation and distribu‐
61         tion are always included.  For example, package.json, README.md,  LI‐
62         CENSE, and so on.
63
64       • If  there  is  a "files" list in npm help package.json, then only the
65         files specified will be included.   (If  directories  are  specified,
66         then  they  will  be  walked recursively and their contents included,
67         subject to the same ignore rules.)
68
69       • If there is a .gitignore or .npmignore file, then  ignored  files  in
70         that and all child directories will be excluded from the package.  If
71         both files exist, then  the  .gitignore  is  ignored,  and  only  the
72         .npmignore  is  used.  .npmignore files follow the same pattern rules
73         https://git-scm.com/book/en/v2/Git-Basics-Record
74         ing-Changes-to-the-Repository#_ignoring as .gitignore files
75
76       • If the file matches certain patterns, then it will never be included,
77         unless explicitly added to  the  "files"  list  in  package.json,  or
78         un-ignored with a ! rule in a .npmignore or .gitignore file.
79
80       • Symbolic links are never included in npm packages.
81
82
83       See npm help developers for full details on what's included in the pub‐
84       lished package, as well as details on how the package is built.
85
86   Configuration
87   tag
88       • Default: "latest"
89
90       • Type: String
91
92
93       If you ask npm to install a package and don't tell it a  specific  ver‐
94       sion, then it will install the specified tag.
95
96       Also  the tag that is added to the package@version specified by the npm
97       tag command, if no explicit tag is given.
98
99       When used by the npm diff command, this is the tag used  to  fetch  the
100       tarball that will be compared with the local files by default.
101
102   access
103       • Default:  'restricted'  for  scoped  packages,  'public' for unscoped
104         packages
105
106       • Type: null, "restricted", or "public"
107
108
109       When publishing scoped packages,  the  access  level  defaults  to  re‐
110       stricted.  If you want your scoped package to be publicly viewable (and
111       installable) set --access=public. The only valid values for access  are
112       public and restricted. Unscoped packages always have an access level of
113       public.
114
115       Note: Using the --access flag on the npm publish command will only  set
116       the  package  access  level  on the initial publish of the package. Any
117       subsequent npm publish commands using the --access flag will  not  have
118       an  effect to the access level. To make changes to the access level af‐
119       ter the initial publish use npm access.
120
121   dry-run
122       • Default: false
123
124       • Type: Boolean
125
126
127       Indicates that you don't want npm to  make  any  changes  and  that  it
128       should only report what it would have done. This can be passed into any
129       of the commands that modify your local installation, eg,  install,  up‐
130       date, dedupe, uninstall, as well as pack and publish.
131
132       Note:  This  is  NOT  honored  by  other  network  related commands, eg
133       dist-tags, owner, etc.
134
135   otp
136       • Default: null
137
138       • Type: null or String
139
140
141       This is a one-time  password  from  a  two-factor  authenticator.  It's
142       needed when publishing or changing package permissions with npm access.
143
144       If  not  set,  and  a  registry  response  fails with a challenge for a
145       one-time password, npm will prompt on the command line for one.
146
147   workspace
148       • Default:
149
150       • Type: String (can be set multiple times)
151
152
153       Enable running a command in the context of the configured workspaces of
154       the  current project while filtering by running only the workspaces de‐
155       fined by this configuration option.
156
157       Valid values for the workspace config are either:
158
159       • Workspace names
160
161       • Path to a workspace directory
162
163       • Path to a parent workspace directory (will result  in  selecting  all
164         workspaces within that folder)
165
166
167       When  set  for the npm init command, this may be set to the folder of a
168       workspace which does not yet exist, to create the folder and set it  up
169       as a brand new workspace within the project.
170
171       This value is not exported to the environment for child processes.
172
173   workspaces
174       • Default: null
175
176       • Type: null or Boolean
177
178
179       Set  to  true  to  run  the  command  in  the context of all configured
180       workspaces.
181
182       Explicitly setting this to false will cause commands  like  install  to
183       ignore workspaces altogether. When not set explicitly:
184
185       • Commands  that  operate  on  the  node_modules tree (install, update,
186         etc.)  will link workspaces into the node_modules folder. -  Commands
187         that  do other things (test, exec, publish, etc.) will operate on the
188         root project, unless one or more  workspaces  are  specified  in  the
189         workspace config.
190
191
192       This value is not exported to the environment for child processes.
193
194   include-workspace-root
195       • Default: false
196
197       • Type: Boolean
198
199
200       Include the workspace root when workspaces are enabled for a command.
201
202       When  false, specifying individual workspaces via the workspace config,
203       or all workspaces via the workspaces flag, will cause  npm  to  operate
204       only on the specified workspaces, and not on the root project.
205
206       This value is not exported to the environment for child processes.
207
208   See Also
209       • npm help package spec
210
211       • npm-packlist package http://npm.im/npm-packlist
212
213       • npm help registry
214
215       • npm help scope
216
217       • npm help adduser
218
219       • npm help owner
220
221       • npm help deprecate
222
223       • npm help dist-tag
224
225       • npm help pack
226
227       • npm help profile
228
229
230
231
232                                September 2022                  NPM-PUBLISH(1)
Impressum