What is np?
The np package is a tool for publishing npm packages with ease. It automates the process of versioning, tagging, and publishing your package to the npm registry, ensuring that all necessary steps are completed correctly and efficiently.
What are np's main functionalities?
Automated Versioning
This command automates the process of versioning your npm package. It prompts you to select the new version, updates the version in package.json, and creates a git tag.
npx np
Automated Publishing
After versioning, np will automatically publish your package to the npm registry. It ensures that all necessary steps, such as running tests and building the project, are completed before publishing.
npx np
Git Integration
np integrates with git to ensure that your repository is in a clean state before publishing. It checks for uncommitted changes and ensures that you are on the correct branch.
npx np
Pre-publish Checks
np runs a series of checks before publishing your package, such as running tests and linting your code, to ensure that your package is in a good state before it is published.
npx np
Other packages similar to np
release-it
release-it is a versatile tool for automating versioning and package publishing. It offers more customization options compared to np, allowing you to define custom scripts and hooks for different stages of the release process.
semantic-release
semantic-release automates the versioning and package publishing process based on the commit messages. It follows the Semantic Versioning specification and generates changelogs automatically. It is more complex to set up compared to np but offers more advanced features.
standard-version
standard-version is a tool for versioning and changelog generation based on conventional commits. It does not publish the package to the npm registry but can be used in conjunction with other tools to automate the release process.
np 
A better npm publish
Why
- Ensures you are publishing from the
master
branch - Ensures the working directory is clean and that there are no unpulled changes
- Reinstalls dependencies to ensure your project works with the latest dependency tree
- Runs the tests
- Bumps the version in package.json and creates a git tag
- Publishes the new version to npm
- Pushes commits and tags to GitHub
Install
$ npm install --global np
Usage
$ np --help
Usage
$ np [major | minor | patch | premajor | preminor | prepatch | prerelease | <version>] (Default: patch)
Options
--any-branch Allow publishing from any branch
--skip-cleanup Skips cleanup of node_modules
--yolo Skips cleanup and testing
Examples
$ np
$ np major
$ np 1.0.2
License
MIT © Sindre Sorhus