node-npm-template

1.0.2 • Public • Published

node-npm-template

Template of Node.JS NPM package: debug in VSCode, test with Mocha, publish to NPM, demo in RunKit and check in Travis CI.

This module is for people who like see working small examples.

Contents of template:

Setup locally

Perform these steps to make initial setup of your work environment:

  1. Install the VSCode
  2. Install the Node.js, it comes with the NPM package manager
  3. Open module's folder in the VSCode
  4. Run npm install in the root folder to install dependencies
  5. Press F5 to run unit tests

Node module

You can edit the module itself here: node-npm-template.js.

Also, check my JS backend / frontend example to learn more about Node.JS modules and Mocha tests.

Sync and async tests

Check out tests/unit-tests.js and tests/functional-tests.js files for examples of tests.

VSCode launch config

Mocha invocation is added to .vscode/launch.json so you can debug tests.

NPM package

NPM package is described in the package.json file. Also notice test script command, which defines NPM module tests (invoked by Travis).

To publish such module simply run:

npm publish

in the folder with package.json file (first time you'll be asked to login with npm adduser command).

You can show nice badge of your NPM package in your README.md file:

NPM:

Travis CI

To integrate with Travis CI we simply need to add .travis.yml file to the root of GitHub repo and init it on Travis CI site.

You can check results build results: travis-ci.org/anpur/node-npm-template or even add nice badge to your README.md file:

Build Status

RunKit custom example

NPM is integrated with RunKit service, which allows user to play with your module in the browser. You can find a link Test node-npm-template in your browser on module's NPM page.

You can add custom RunKit example by adding runkitExampleFilename field to your package.json which point to some file, in this case runkit-example.js.

Package Sidebar

Install

npm i node-npm-template

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • anpur