talira

A better npm publish: checks, tests, version bump, tag and publish in one step

open sourceMITfree

np is Sindre Sorhus's command-line tool for publishing an npm package safely. Run interactively, it checks you're on the release branch with a clean, up-to-date working tree, reinstalls dependencies, checks Node.js and npm versions, runs the tests, bumps the version in package.json and the lockfile, creates a git tag, publishes (optionally under a dist-tag), pushes commits and tags to GitHub or GitLab, and opens a prefilled GitHub release draft. It rolls the project back if publishing fails, supports two-factor authentication and has a dry-run mode. It works with npm 10+, pnpm, Bun and Yarn.

Problems it solves

  • publish a new version of my npm package without forgetting to run the tests or push the tag
  • bump the version, tag it and publish to npm in one command
  • roll back automatically if npm publish fails

Features

  • interactive publishing UI
  • checks branch, clean working tree and unpulled changes
  • runs tests and reinstalls dependencies first
  • bumps the version and creates a git tag
  • rolls back if publishing fails
  • dry-run mode
  • prefilled GitHub release draft
  • npm, pnpm, Bun and Yarn

Limitations

  • It doesn't support monorepos.1
  • It's meant to be run locally and interactively, not in CI.1

Alternatives

The same job

These do what np does.

  1. semantic-release Fully automated version management and package publishing
  2. Release It! A generic CLI to automate versioning and package publishing
  3. bump Bump a Ruby gem's version number, commit it and tag it
  4. commit-and-tag-version Bump versions, write the CHANGELOG and tag releases from Conventional Commits
  5. gem-release Release Ruby gems with bump, tag and release commands
  6. Changesets A tool to manage versioning and changelogs with a focus on monorepos

Compare np with the top 3