Publish node package on NPM best practices

As a contributor of some packages on npm, I will try my best to give you some tips on how to publish package on npm.

NPM ?

Node package manager is the official package manager for nodejs.
npm doc

Semver

You must use Semver versioning for your package.

If you use Grunt or Gulp, you can use a plugin to release a major or minor version, and automate your release process (grunt-bump, gulp-bump)

devDependencies

Use devDependencies key in your package.json to define dependencies needed in your build or test process.

Install package as dev dependencies :

npm install <package-name> --save-dev  

You must put your test framework, grunt|gulp plugins, jshint, in devDependencies.

.npmignore

You can use a .npmignore file at the root of your project to keep your files and directories out of your package. For example, tests and demo directories can be excluded.

.npmignore example file

test  
.jshintrc
.travis.yml

Test your module

Before publishing your node package, it's really interesting to test it installed, globally or in another project.

Global module, if your package define global module you can install this using.

cd your_module_directory  
npm install . -g  
# Test

You can also test your module in another project using this command:

cd test_project  
npm install you_module-directory  
# Test

npm documentation : https://www.npmjs.org/doc/
Semver: http://semver.org/
Grunt bump: https://github.com/vojtajina/grunt-bump
Gulp bump: https://github.com/stevelacy/gulp-bump