node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


NPM Package Generator version License

an opinionated npm package template

Build Status Downloads Code Climate Coverage Status Dependency Status Dependencies

The Opinionated Parts

I follow the below set of rules in all projects, npm-package-generator ensures all those rules are followed:

  • write in ES2015, ES2016 & ES2017 syntax, (supports all plugins in Babel that are considered latest
  • outputs npm ready packages supporing all LTS versions of Node & Browsers
  • write tests in ES2017 and run them using tap without needing to compile
  • generate coverage reports without needing to compile
  • runs tests on travis targeting all LTS versions of Node
  • uses .editorconfig for maintaining consistent coding styles enforced by echint
  • uses standard to follow JavaScript Standard Style Guide
  • ignores ./build folder from git
  • use the most permissive open source license (currently ISC)
  • follow a preferred folder tree & npm's default expected file naming (see below)
  • always expose your package's compiled library modules (see below)
  • keep your package lean, only include useful files (compiled & sources) for developers (see package.json > files)
  • use a standard template for README files.
  • Testing
    • use tap for testing & nyc to generate coverage reports
    • use travis optimizations and leverage folder caching.
    • use standard and echint for linting files
    • publish coverage reports to codeclimate (requires configuring travis with the appropriate CODECLIMATE_REPO_TOKEN)
Folder Tree
    ├── build
    │   ├── browsers (compiled to last 2 versions of top browsers)
    │   │   └── index.js
    │   ├── node4 (compiled to Node v4) (default export)
    │   │   └── index.js
    │   ├── node6 (compiled to Node v6)
    │   │   └── index.js
    │   └── node7 (compiled to Node v7)
    │       └── index.js
    ├── LICENSE
    ├── package.json
    ├── src
    │   └── index.js
    └── test
        ├── fixtures
        └── index.js
  • /build: compiled library files, this is the default exposed output.
  • /src: source library files: all common business logic, use this folder for your code

Work in progress...

This is a work in progress, and will likely be in this state forever!

I will be updating this frequently as common practices change over time, or as I learn new trick.

please reach out to share any feedback & contribution!


npm install --only=production --save npm-package-generator


$ npm-package-generator new my-awesome-package ~/Projects/my-awesome-package
    npm-package-generator new <name> [path] [options]

      --help             Show help                                         [boolean]
      --author, -a       Author Name            [required] [default: "Ahmad Nassri"]
      --description, -d  Package Description
      --email, -e        Author Email  [required] [default: ""]
      --github, -g       Github Username         [required] [default: "ahmadnassri"]
      --website, -w      Author Website
                                [required] [default: ""]
      --install, -i      Install Dependencies?           [required] [default: false]



import generator from 'npm-package-generator'
options = {
  path: '~/Projects/my-awesome-package',
  name: 'my-awesome-package',
  description: 'my-awesome-package',
  author: 'Ahmad Nassri',
  email: '',
  website: '',
  github: 'ahmadnassri',
  install: false
  .then(files => console.log(files)) //-> [array of files created]


option description default
name package name
path installation path
author author name process.env.NPM_AUTHOR_NAME
description package description process.env.NPM_PACKAGE_DESCRIPTION
author author name process.env.NPM_AUTHOR_NAME
email author email process.env.NPM_AUTHOR_EMAIL
website author website process.env.NPM_AUTHOR_WEBSITE
github github account process.env.NPM_GITHUB_USERNAME
install run npm install and update dependencies false

©️  ·  License: ISC  ·  Github: @ahmadnassri  ·  Twitter: @ahmadnassri