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.
Node package manager is the official package manager for nodejs. npm doc
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)
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
.
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
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_directorynpm install . -g# Test
You can also test your module in another project using this command:
cd test_projectnpm 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