This way, executing npm run lint will execute eslint to against our src folder. No need for a grunt or gulp plugin.

Remember: npm run expands the [scope of $PATH](https://en.wikipedia.org/wiki/PATH_(variable) by prepending $PWD/node_modules/.bin to it. Exactly like PATH="./node_modules/.bin:$PATH" npm run lint would do. This way you can run any executables provided by local dependencies.

npm version {major,minor,patch}

Considering our current package version is 1.0.0, the npm version {something} feature acts as following:

npm version major → 2.0.0 (creates git tag v2.0.0);

npm version minor → 1.1.0 (creates git tag v1.1.0);

npm version patch → 1.0.1 (creates git tag v1.0.1).

The one liner updates the version field in the package.json file, runs git tag and git commit for us.

npm version hooks

The npm command introduced the preversion and postversion scripts a while ago too. They are executed as follows:

preversion: performs operations before altering the version number;

version: performs operations after having altered the version number and before the git commit;

postversion: performs operations after the git commit.

Artefacts can be added to the npm version git commit since npm@2.13.0 – mid-July 2015. This is what makes the workflow handy and streamlined.

npm release process example

We will use a CHANGELOG generator to illustrate the previous statement: github-changes. We want the changelog to be in sync with the new version number and to be committed prior to the npm version change.

npm version from-git

I stumbled on two alternatives while researching this article via git blame:

npm version <semver>;

npm version from-git.

The last one is particularly interesting as it reverses the previous workflow and gives back control to git as a primary publishing tool.
Whereas npm version {major,minor,patch} would compute the version for you, npm version from-git will read the version from the git history.

triggernpm version (up to you to configure the various preversion, version and postversion scripts);

publish the new package to the npm registry.

Conclusion

The npm command became a powerful release tool since summer 2015, all thanks to a simple lifecycle change.

Wether you choose to use one of the approach or not is up to you. I have a personal preference for npm version {major,minor,patch} but I kind of like the idea of the CI doing all the work with npm version from-git on a new git tag rather than having to rely on my machine setup. Or anybody machine setup.