# np

> Interactive release tool for npm packages that checks the working tree, runs tests, bumps versions, creates tags, publishes, and pushes to Git.

Stars: 7.7k · Language: JavaScript · License: MIT · Categories: Dev Tools

- Repository: https://github.com/sindresorhus/np
- Page: https://www.trmn.sh/tools/np

## Install

- npm: `npm install --global np`

## Overview

np is a release tool for npm packages that replaces a bare `npm publish` with a scripted sequence of checks and steps. Run `np` with no arguments to get an interactive UI, or pass a version such as `patch`, `minor`, `major`, `prerelease`, or an explicit `1.2.3`. It checks that you are on the release branch (`main` or `master` by default), that the working directory is clean, and that there are no unpulled changes. It then reinstalls dependencies, checks Node.js and npm version support, and runs the tests.

After those checks, np bumps the version in package.json and package-lock.json and creates a git tag. It publishes to npm, optionally under a dist-tag with `--tag`, and pushes commits and tags to GitHub or GitLab. It also stops pre-release versions from being published under the `latest` dist-tag. Afterward it opens a prefilled GitHub Releases draft. It warns about extraneous files in the package, and it supports two-factor authentication, including enabling 2FA on new packages.

Other options include `--dry-run` to list the tasks without executing them, `--contents` to publish a subdirectory, `--test-script` to run a different test script, `--remote` to push to a different git remote, `--provenance` for npm provenance statements, and `--stage` for staged publishing (npm and pnpm only). Configuration can be set globally or per project, in a `np` field in package.json or in `.np-config.json`, `.np-config.js`, `.np-config.cjs` or `.np-config.mjs`. np supports npm 10+, pnpm 11+, Bun, and Yarn (Classic and Berry), as well as GitHub Packages and custom registries.

It is meant for maintainers who publish packages from a local machine. The README says monorepos are not supported and that CI is not an ideal environment for np. It requires Node.js 22 or later, npm 10 or later, and Git 2.11 or later.

### Installation

```bash
# via npm
npm install --global np
```

![np interactive UI](https://media.trmn.sh/cached/eef534e875eaa01d0e531fa0e1400a932456cc59c62c001c2a06a1423ab2389d.png)

## Alternatives

- [Plop](https://www.trmn.sh/tools/plop.md): Micro-generator framework that runs inquirer prompts and Handlebars templates from a plopfile to create consistent files from the terminal. (JavaScript, 7.7k stars)
- [release-it](https://www.trmn.sh/tools/release-it.md): Generic CLI for automating releases: version bumps, git commit/tag/push, changelogs, GitHub/GitLab releases, and npm publishing, with hooks and plugins. (JavaScript, 9.1k stars)
- [mermaid-cli](https://www.trmn.sh/tools/mermaid-cli.md): Command-line tool (mmdc) that renders Mermaid diagram definitions and Markdown files with Mermaid code blocks to SVG, PNG, or PDF. (JavaScript, 5.2k stars)
- [DocToc](https://www.trmn.sh/tools/doctoc.md): Node.js CLI that generates and updates tables of contents in Markdown files, with anchor links compatible with GitHub, GitLab, Bitbucket, Ghost and nodejs.org. (JavaScript, 4.5k stars)
- [terminalizer](https://www.trmn.sh/tools/terminalizer.md): Terminal session recorder that generates animated GIF images from command-line sessions (JavaScript, 16.2k stars)

---

Canonical: https://www.trmn.sh/tools/np
