This article will show you how to configure npm modules in a proper way and use Buddy to automatically test and publish your packages
This guide will show you how to:
The first thing you need to do is to install the following things:
Begin with creating a folder and initializing a Git repository so that your package remains safe under version control:
mkdir my_first_npm_modulecd my_first_npm_modulegit init
Next, add package.json
which will contain the details of your module. You can easily do that by running this command:
npm init
You will be asked to provide the information about your package:
index.js
)Once done, check the contents of package.json
. It should look like this:
{ "name": "buddy-demo-package", "version": "1.0.3", "description": "",
"main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC"}
In index.js
the functions should be provided as a property of the exports
object. Here's an example:
exports.printMsg = function() {console.log("My first package message");}
Once everything is set, make sure to commit your files to the repo…