Create a new node module with all the right stuff.
Last updated a year ago by goto-bus-stop .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @goto-bus-stop/create 
SYNC missed versions from official npm registry.


Create a new node module with all the right stuff.

npm travis standard downloads


module-init is a command-line tool for generating a new node module.

The following list of files are created based on user input:

  • README.md
    • Automatically generates title, description, and some tasteful badges (version, build status, code style).
    • Auto-populates install, usage, contributing, and license sections with relevant info.
  • LICENSE.md
    • Options: Apache-2.0, BSD-3-Clause, CC0-1.0, ISC, MIT, UNLICENSED.
    • Optionally generates contributing guidelines based on CONTRIBUTING.md boilerplate.
  • package.json
    • Fills out all standard fields.
    • Adds code style linter (standard to devDependencies.
    • Adds tape & tap-spec to devDependencies.
    • Sets up npm test script.
    • Runs fixpack.
  • .travis.yml
    • Covers Node.js 4 and 6.
  • .gitignore
    • Ignores node_modules directory.
  • index.js
    • A blank module entry point file.
  • test/index.js
    • A boilerplate test file using tape.

Optionally runs git init and npm install in the new module directory.


npm install @goto-bus-stop/create -g



$ npm init @goto-bus-stop --help
Usage: @goto-bus-stop/create [options]
    --dir, -d             specify module directory (default: cwd)
    --version, -v         show version information
    --force, -f           skip prompt and init with defaults
    --help, -h            show help


~ $ npm init @goto-bus-stop -d new-project
? name: new-project
? version: 1.0.0
? description:
? keywords:
? license: ISC
? private: No
? git init: Yes
? npm install: Yes
Initialized empty Git repository in /Users/yourname/new-project/.git/
✓ .gitignore created
✓ .travis.yml created
✓ CHANGELOG.md created
✓ CONTRIBUTING.md created
✓ LICENSE created
✓ README.md created
✓ package.json created
✓ index.js created
✓ test/index.js created
tape@4.0.3 node_modules/tape
tap-spec@4.0.2 node_modules/tap-spec
standard@5.0.2 node_modules/standard
✓ new-project initialized

Node API

module-init can also be required as a regular node module.

Configuration properties from other sources (.gitconfig, current working directory) will not be automatically used as defaults in this mode. All required properties need to be passed in explicitly.

var moduleInit = require('module-init')

var options = {
  pkgName: 'cool-package',          // required
  pkgVersion: '1.0.0',              // required
  usrName: 'Your Name',             // required
  usrEmail: 'your@email.com',       // required
  usrGithub: 'githubUsername'       // required
  pkgDescription: 'description',    // optional
  pkgKeywords: 'one, two, three',   // optional
  pkgContributing: true,            // optional, default: true
  pkgLicense: 'ISC',                // optional, default: ISC
  private: true,                    // optional, default: false (omitted if false)
  dir: 'project-directory'          // optional: default: cwd

  .on('create', function (filename) {
    console.log(`${filename} created`)
    // file created
  .on('warn', function (message) {
    console.log(`warning: ${message}`)
    // something weird but non-critical happened
  .on('err', function (err) {
    // something went horribly wrong! stop everything!
  .on('done', function (result) {
    console.log(result) // object containing module metadata
    // done!
  .run() // run the thing

moduleInit returns an event emitter that emits create, warn, err, and done.

moduleInit.on(string, function) works as demonstrated in the example above.

moduleInit.run() runs the initialization process. It also calls moduleInit.validate() internally before proceeding and will emit an err event if required options are missing. Event listeners need to be set before moduleInit.run() is called.

moduleInit.validate() returns an array of missing required options. It returns an empty array if everything's fine. This method is really just for internal use, but is exposed for testing and convenience.

Take a look at bin/cli.js to see how the API is being used by the CLI.


Contributions welcome! Please read the contributing guidelines before getting started.


module-init is only possible due to the excellent work of the following collaborators:

bcomnes GitHub/bcomnes
Flet GitHub/Flet
paulcpederson GitHub/paulcpederson
ungoldman GitHub/ungoldman

See Also



Current Tags

  • 2.2.0                                ...           latest (a year ago)

7 Versions

  • 2.2.0                                ...           a year ago
  • 2.1.0                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.8.0                                ...           3 years ago
  • 1.7.0                                ...           3 years ago
  • 1.6.0                                ...           3 years ago
Maintainers (1)
Today 0
This Week 0
This Month 10
Last Day 0
Last Week 7
Last Month 2
Dependencies (10)
Dev Dependencies (6)
Dependents (0)

Copyright 2014 - 2017 © taobao.org |