gat-bypass-2fa-docs
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: npm-publish |
| 3 | section: 1 |
| 4 | description: Publish a package |
| 5 | github_repo: npm/cli |
| 6 | github_branch: release/v6 |
| 7 | github_path: docs/content/commands/npm-publish.md |
| 8 | redirect_from: |
| 9 | - /cli-documentation/v6/cli-commands/npm-publish |
| 10 | - /cli-documentation/v6/cli-commands/publish |
| 11 | - /cli-documentation/v6/commands/npm-publish |
| 12 | - /cli-documentation/v6/commands/publish |
| 13 | - /cli-documentation/v6/npm-publish |
| 14 | - /cli-documentation/v6/publish |
| 15 | - /cli/v6/cli-commands/npm-publish |
| 16 | - /cli/v6/cli-commands/publish |
| 17 | - /cli/v6/commands/publish |
| 18 | - /cli/v6/npm-publish |
| 19 | - /cli/v6/publish |
| 20 | --- |
| 21 | |
| 22 | ### Synopsis |
| 23 | |
| 24 | ```bash |
| 25 | npm publish [<tarball>|<folder>] [--tag <tag>] [--access <public|restricted>] [--otp otpcode] [--dry-run] |
| 26 | |
| 27 | Publishes '.' if no argument supplied |
| 28 | Sets tag 'latest' if no --tag specified |
| 29 | ``` |
| 30 | |
| 31 | ### Description |
| 32 | |
| 33 | Publishes a package to the registry so that it can be installed by name. All files in the package directory are included if no local `.gitignore` or `.npmignore` file exists. If both files exist and a file is ignored by `.gitignore` but not by `.npmignore` then it will be included. See [`developers`](/cli/v6/using-npm/developers) for full details on what's included in the published package, as well as details on how the package is built. |
| 34 | |
| 35 | By default npm will publish to the public registry. This can be overridden by specifying a different default registry or using a [`scope`](/cli/v6/using-npm/scope) in the name (see [`package.json`](/cli/v6/configuring-npm/package-json)). |
| 36 | |
| 37 | - `<folder>`: A folder containing a package.json file |
| 38 | |
| 39 | - `<tarball>`: A url or file path to a gzipped tar archive containing a single folder with a package.json file inside. |
| 40 | |
| 41 | - `[--tag <tag>]` Registers the published package with the given tag, such that `npm install <name>@<tag>` will install this version. By default, `npm publish` updates and `npm install` installs the `latest` tag. See [`npm-dist-tag`](npm-dist-tag) for details about tags. |
| 42 | |
| 43 | - `[--access <public|restricted>]` Tells the registry whether this package should be published as public or restricted. Only applies to scoped packages, which default to `restricted`. If you don't have a paid account, you must publish with `--access public` to publish scoped packages. |
| 44 | |
| 45 | - `[--otp <otpcode>]` If you have two-factor authentication enabled in `auth-and-writes` mode then you can provide a code from your authenticator with this. If you don't include this and you're running from a TTY then you'll be prompted. |
| 46 | |
| 47 | - `[--dry-run]` As of `npm@6`, does everything publish would do except actually publishing to the registry. Reports the details of what would have been published. |
| 48 | |
| 49 | Fails if the package name and version combination already exists in the specified registry. |
| 50 | |
| 51 | 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 [`npm unpublish`](/cli/v6/commands/npm-unpublish). |
| 52 | |
| 53 | As of `npm@5`, both a sha1sum and an integrity field with a sha512sum of the tarball will be submitted to the registry during publication. Subsequent installs will use the strongest supported algorithm to verify downloads. |
| 54 | |
| 55 | Similar to `--dry-run` see [`npm pack`](/cli/v6/commands/npm-pack), which figures out the files to be included and packs them into a tarball to be uploaded to the registry. |
| 56 | |
| 57 | ### See Also |
| 58 | |
| 59 | - [npm registry](/cli/v6/using-npm/registry) |
| 60 | - [npm scope](/cli/v6/using-npm/scope) |
| 61 | - [npm adduser](/cli/v6/commands/npm-adduser) |
| 62 | - [npm owner](/cli/v6/commands/npm-owner) |
| 63 | - [npm deprecate](/cli/v6/commands/npm-deprecate) |
| 64 | - [npm dist-tag](/cli/v6/commands/npm-dist-tag) |
| 65 | - [npm pack](/cli/v6/commands/npm-pack) |
| 66 | - [npm profile](/cli/v6/commands/npm-profile) |