• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2section: cli-commands
3title: npm-publish
4description: Publish a package
5---
6
7# npm-publish(1)
8
9## Publish a package
10
11### Synopsis
12```bash
13npm publish [<tarball>|<folder>] [--tag <tag>] [--access <public|restricted>] [--otp otpcode] [--dry-run]
14
15Publishes '.' if no argument supplied
16Sets tag 'latest' if no --tag specified
17```
18
19### Description
20
21Publishes a package to the registry so that it can be installed by name. All
22files in the package directory are included if no local `.gitignore` or
23`.npmignore` file exists. If both files exist and a file is ignored by
24`.gitignore` but not by `.npmignore` then it will be included.  See
25[`developers`](/using-npm/developers) for full details on what's included in the published package, as well as details on how the package is built.
26
27By default npm will publish to the public registry. This can be overridden by
28specifying a different default registry or using a [`scope`](/using-npm/npm-scope) in the name (see [`package.json`](/configuring-npm/package-json)).
29
30* `<folder>`:
31  A folder containing a package.json file
32
33* `<tarball>`:
34  A url or file path to a gzipped tar archive containing a single folder
35  with a package.json file inside.
36
37* `[--tag <tag>]`
38  Registers the published package with the given tag, such that `npm install
39  <name>@<tag>` will install this version.  By default, `npm publish` updates
40  and `npm install` installs the `latest` tag. See [`npm-dist-tag`](npm-dist-tag) for
41  details about tags.
42
43* `[--access <public|restricted>]`
44  Tells the registry whether this package should be published as public or
45  restricted. Only applies to scoped packages, which default to `restricted`.
46  If you don't have a paid account, you must publish with `--access public`
47  to publish scoped packages.
48
49* `[--otp <otpcode>]`
50  If you have two-factor authentication enabled in `auth-and-writes` mode
51  then you can provide a code from your authenticator with this. If you
52  don't include this and you're running from a TTY then you'll be prompted.
53
54* `[--dry-run]`
55  As of `npm@6`, does everything publish would do except actually publishing
56  to the registry. Reports the details of what would have been published.
57
58Fails if the package name and version combination already exists in
59the specified registry.
60
61Once a package is published with a given name and version, that
62specific name and version combination can never be used again, even if
63it is removed with [`npm unpublish`](/cli-commands/npm-unpublish).
64
65As of `npm@5`, both a sha1sum and an integrity field with a sha512sum of the
66tarball will be submitted to the registry during publication. Subsequent
67installs will use the strongest supported algorithm to verify downloads.
68
69Similar to `--dry-run` see [`npm pack`](/cli-commands/npm-pack), which figures out the files to be
70included and packs them into a tarball to be uploaded to the registry.
71
72### See Also
73
74* [npm registry](/using-npm/registry)
75* [npm scope](/using-npm/scope)
76* [npm adduser](/cli-commands/adduser)
77* [npm owner](/cli-commands/owner)
78* [npm deprecate](/cli-commands/deprecate)
79* [npm dist-tag](/cli-commands/dist-tag)
80* [npm pack](/cli-commands/pack)
81* [npm profile](/cli-commands/profile)
82