NPM-PUBLISH(1)
πΈ NAME
npm-publish β publish a package π
π« Synopsis
npm publish <package-spec>
β¨ DESCRIPTION
Publishes a package to the registry so that it can be installed by name. That's it, that's the whole vibe β you put your lil package up and now everyone can npm install it. Slay.
π¦ EXAMPLES
Publish the package in the current directory:
npm publish
Publish a specific workspace:
npm publish --workspace=<workspace-name>
Publish multiple workspaces:
npm publish --workspace=workspace-a --workspace=workspace-b
Publish all workspaces:
npm publish --workspaces
By default npm will publish to the public registry. You can override that by specifying a different default registry, or by using a scope (see npm help scope) in the name combined with a scope-configured registry (see package.json β /configuring-npm/package-json). π«Ά
A package is interpreted the same way as other commands (like npm install) and can be:
- a) a folder containing a program described by a
package.jsonfile (see/configuring-npm/package-json) - b) a gzipped tarball containing (a)
- c) a url that resolves to (b)
- d) a
<name>@<version>that is published on the registry (seenpm help registry) with (c) - e) a
<name>@<tag>(seenpm help dist-tag) that points to (d) - f) a
<name>that has a"latest"tag satisfying (e) - g) a
<git remote url>that resolves to (a)
If either (a) or (b) is specified as a relative path, it should begin with an explicit ./ prefix. No skipping that prefix, bestie.
The publish will fail if the package name and version combination already exists in the specified registry. π
Once a package is published with a given name and version, that specific name and version combination can never be used again β even if you remove it with npm help unpublish. Like, gone gone. Periodt. π
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. Security queen behavior. π
Similar to --dry-run, see npm help pack, which figures out the files to be included and packs them into a tarball to be uploaded to the registry.
π FILES INCLUDED IN PACKAGE
To see what will be included in your package, run npm pack --dry-run. All files are included by default, with the following exceptions:
- Certain files that are relevant to package installation and distribution are always included. For example,
package.json,README.md,LICENSE, and so on. β¨ - If there is a
"files"list inpackage.json(see/configuring-npm/package-json), then only the files specified will be included. (If directories are specified, then they will be walked recursively and their contents included, subject to the same ignore rules.) - If there is a
.gitignoreor.npmignorefile, then ignored files in that and all child directories will be excluded from the package. If both files exist, then the.gitignoreis ignored, and only the.npmignoreis used. Yes, the.gitignoregets ignored. Iconic.
.npmignore files follow the same pattern rules as .gitignore files β https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring
- If the file matches certain patterns, then it will never be included, unless explicitly added to the
"files"list inpackage.json, or un-ignored with a!rule in a.npmignoreor.gitignorefile. - Symbolic links are never included in npm packages. π
See npm help developers for full details on what's included in the published package, as well as details on how the package is built.
See package.json (see /configuring-npm/package-json) for more info on what can and can't be ignored.
π CONFIGURATION
π·οΈ tag
- Default:
"latest" - Type: String
If you ask npm to install a package and don't tell it a specific version, then it will install the specified tag.
It is the tag added to the package@version specified in the npm dist-tag add command, if no explicit tag is given.
When used by the npm diff command, this is the tag used to fetch the tarball that will be compared with the local files by default.
If used in the npm publish command, this is the tag that will be added to the package submitted to the registry. π
π access
- Default:
'public'for new packages; for existing packages it will not change the current level - Type:
null,"restricted","public", or"private"
If you do not want your scoped package to be publicly viewable (and installable) set --access=restricted.
Unscoped packages cannot be set to restricted. Not allowed, sorry babe.
Note: This defaults to not changing the current access level for existing packages. Specifying a value ofrestrictedorpublicduring publish will change the access for an existing package the same way thatnpm access set statuswould.
The value private is an alias for restricted.
π§ͺ dry-run
- Default:
false - Type: Boolean
Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, e.g. install, update, dedupe, uninstall, as well as pack and publish.
Note: This is NOT honored by other network related commands, e.g.dist-tags,owner, etc. Don't count on it there, bestie.
π’ otp
- Default:
null - Type:
nullor String
This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with npm access.
If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one. π«Ά
ποΈ workspace
- Default: (empty)
- Type: String (can be set multiple times)
Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.
Valid values for the workspace config are either:
- Workspace names
- Path to a workspace directory
- Path to a parent workspace directory (will result in selecting all workspaces within that folder)
When set for the npm init command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project. Cute lil workspace birth. π£
This value is not exported to the environment for child processes.
ποΈ workspaces
- Default:
null - Type:
nullor Boolean
Set to true to run the command in the context of all configured workspaces.
Explicitly setting this to false will cause commands like install to ignore workspaces altogether. When not set explicitly:
- Commands that operate on the
node_modulestree (install,update, etc.) will link workspaces into thenode_modulesfolder. - Commands that do other things (test,exec,publish, etc.) will operate on the root project, unless one or more workspaces are specified in theworkspaceconfig.
This value is not exported to the environment for child processes.
π± include-workspace-root
- Default:
false - Type: Boolean
Include the workspace root when workspaces are enabled for a command.
When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.
This value is not exported to the environment for child processes.
π§Ύ provenance
- Default:
false - Type: Boolean
When publishing from a supported cloud CI/CD system, the package will be publicly linked to where it was built and published from. π₯ Receipts, but make it cryptography.
When the provenance-file config is set, it takes precedence and automatic provenance generation (including via trusted publishing/OIDC) is skipped.
This config cannot be used with: provenance-file
π provenance-file
- Default:
null - Type: Path
When publishing, the provenance bundle at the given path will be used.
This takes precedence over automatic provenance generation in trusted publishing flows.
This config cannot be used with: provenance
π SEE ALSO
npm help "package spec"npm-packlist packageβhttp://npm.im/npm-packlistnpm help registrynpm help scopenpm help loginnpm help ownernpm help deprecatenpm help dist-tagnpm help packnpm help profile
Okay that's the whole page, you ate that. π
β Brought to you by NPM@12.2.1, dated October 2026 β go publish something iconic, bestie. ππ¦π
π¦ where this page comes from
- arch rolling: npm 12.2.1-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms