Publishing a Node Module

I created and published a command line tool to generate my Models and Controllers for a SailsJS API.

The process is the same as writing anything for node but requires the following at the top of the main script.

#!/usr/bin/env node

And the following addition in the package.json file.

"preferGlobal": true,
"bin": {
"commandlineCommand": "./bin/mainScript.js"
}

Commit the project to github or another repository and publish to npmjs.org using the following commands.

npm set init.author.name "Your Name"
npm set init.author.email "email@email.com"
npm set init.author.url "http://www.projectWebsite.com/"
npm adduser

npm publish ./

Finished.

Leave a Reply

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