Publishing Packages to NPM

Screen Shot 2014-11-16 at 3.49.04 AM

I just published my first package – profanity-scanner – to npm, and it was really easy once I figured out the steps I had to take (npm doesn’t offer a guide, just docs you have to sort through). In three days I’ve had over 60 downloads already!

Here’s all you need to do to get your package up on npm:

  1. Write your node module like any other node module, but keep it in an isolated folder
  2. Add your user info if you haven’t already like this (one-time only)
    $ npm set "Your Name"
    $ npm set ""
    $ npm set ""
    $ npm adduser
  3. Create a package.json file using $ npm init and fill out the fields
  4. npm publish

If you want to be a good citizen, and have people actually use your code, I’d recommend adding a README to your package as well.

Leave a Reply

Your email address will not be published. Required fields are marked *