Publishing Packages to NPM
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:
- Write your node module like any other node module, but keep it in an isolated folder
-
Add your user info if you haven’t already like this (one-time only)
$ npm set init.author.name "Your Name" $ npm set init.author.email "your@email.com" $ npm set init.author.url "http://yoursite.com" $ npm adduser
- Create a
package.json
file using$ npm init
and fill out the fields - 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.