node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »



Spawns a bootstrap npm package.

NpmBoot is two things:

  1. A tool for beginners who aren't quite sure how to create a working npm package.
  2. A tool for users of all experience levels who want a quick way to get a package started.

Calling npmboot from the command line generates a bare-bones npm package in a given directory with all the files necessary to execute the generated app right out of the box.


In order to use NpmBoot, you'll first need to install Node.js and npm.

Once you have Node and npm installed open the command line and run...

~$ npm install npmboot

You are now ready to start creating npm packages!


There are two ways to use NpmBoot: one from the command line and one from JavaScript.

From the command line, these are your options:

Usage: npmboot [directory] [options]
Passing a directory path to npmboot will cause it to spawn a new
npm package in that directory.  If you do not pass in a directory,
npmboot will place your new package in the current directory.
  -v,         --version          Display the version of npmboot.
  -h,         --help             Display help information.
  -a NAME,    --app-name NAME    NAME becomes the name of your app.
  -j [NAME],  --js-main [NAME]   The filename of your JavaScript API.
                                 Defaults to --app-name or `api.js`.

In other words, here are a few ways you might call the app:

~$ npmboot
# Creates a new package within the current directory under a
# default name and without a JavaScript API file.
~$ npmboot ./outputdir -a myApp -j main.js
# Creates a new package in the 'outputdir' directory.
# The app will be called 'myApp' and it will have
# a JavaScript API file called 'main.js'.
~$ npmboot -a myApp -j
# Creates a new package in the current directory.
# The app will be called 'myApp' and it will have
# a JavaScript API file called 'myApp.js'

Remember, NpmBoot can only generate packages inside empty directories.

To use NpmBoot from JavaScript, first require it as a Node.js module:

var npmboot = require('npmboot');

Then call it with 3 arguments: outputDir, appName, jsAPIfileName

npmboot('./', 'myApp', 'main.js');

If you pass in something falsy for the jsAPIfileName argument, it will default to your argument for appName. If you pass in something falsy for the appName argument, it will default to "default-app-name". If you pass in something falsy for the outputdir argument, it will default to the current directory.

How it works...

In order to create a working npm package, there are a few things you need. First, you'll need a file that gets executed when you call your application from the command line. If you want to be able to use your application as a Node module, you'll also need a JavaScript file that creates an API that can be accessed with JavaScript.

Other than that, you need a README file in order to describe your application, and a "package.json" file that npm will use to properly construct your application.

NpmBoot generates all of these files and puts enough information in them that you can actually execute your new package right out of the box. For convenience, it generates three other files: a blank ".npmignore" file, a blank ".gitignore" file, and a super simple bash argument parser to help you deal with flagged arguments that will come in from the command line.

Here is the full structure of files NpmBoot will generate:

|- bin:
|   |- application-file
|- lib:
|   |- argparser.js
|- .npmignore
|- .gitignore
|- package.json
|- javascript-API-file.js

After generating these files, open them up and alter them in whatever ways you'd like. Whenever you're ready (and, again, you can do this immediately after generating), access your package directory from the command line and run ~$ npm link. This will allow you to use your application as if it were a finished product that had just been installed.

For more information on publishing a completed package, visit the npm docs.