Home·Terminal commands

npm publish

Packages and runtimes

Usage

npm publish [--access public] [--tag <tag>]

Uploads the package to the registry; a scoped name is private by default so --access public is needed, and a version number can never be reused, so check the file list with --dry-run first.

Common flags

FlagMeaning
--access publicrequired for a scoped package, which is private by default
--tag <tag>publish under a tag such as next, leaving latest alone
--dry-runshow the file list and version without uploading
--otp <code>pass a two-factor code
--provenanceattach a signed build statement from CI

Examples

npm publish --dry-run

shows exactly which files would ship

npm publish --access public

publishes @scope/name so anyone can install it

npm publish --tag next

a prerelease that npm install does not pick up

The question is always what goes where: inside this project, or on the whole machine.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does npm publish do?

Uploads the package to the registry; a scoped name is private by default so --access public is needed, and a version number can never be reused, so check the file list with --dry-run first.

Q. How do I type it?

npm publish [--access public] [--tag <tag>] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

5 are listed here; the full set is in man npm. This command sits under Packages and runtimes.

Related commands

man page: man npm-publish