Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A furry little helper for dealing with optional NPM dependencies
Tag: v0.0.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Squirrel is a helpful node module that assists you requiring your optionalDependencies into your application for runtime use rather than using dependencies.

Build Status

Why Squirrel?

Because personally, I really don't like the sitting waiting for a node package to install a whole swag of dependencies because it requires them for some functionality that I don't intend to use. I believe using squirrel will enable certain types of packages to have a leaner core with properly managed and installable optional dependencies.

Exmaple Usage

If you are using optionalDependencies in your application try "squirreling" them rather than requiring them. (NOTE: Squirreling is an asynchronous operation):

var squirrel = require('squirrel');

squirrel('coffee-script', function(err, coffee) {
    // do something magical with coffeescript...

If you need multiple modules, then squirrel is happy to play in a way similar to the way AMD module loaders do:

squirrel(['coffee-script', 'jade'], function(err, coffee, jade) {
    // do something with both coffeescript and jade...

Squirrel Options

A squirrel's got to have options. The demands on the modern squirrel mean that having options is important, and this squirrel is not different. Here are the options that squirrel supports in a 2nd (optional) argument.

// initialise the squirrel defaults
squirrel.defaults = {
    // whether or not the interactive process that will allow the user to request 
    // the package will be installed or not
    allowInstall: false,

    // initialise the prompt message
    promptMessage: 'Package <%= target %> is required. Permit installation? [Y/n]',

    // the current working directory in which npm will be run to install the package
    cwd: process.cwd(),

    // the path to the installer, by default we are hoping `npm` will exist in the PATH
    installer: 'npm',

    // install command
    installCommand: '<%= opts.installer %> install <%= target %>@<%= version %>',

    // uninstall command
    uninstallCommand: '<%= opts.installer %> rm <%= target %>',

    // specify the target output stream
    outputStream: process.stderr

The default options can be modified through modifying them in the squirrel.defaults object.

Shouldn't Squirrel be dependency free?

You could argue that given squirrel's mission is to reduce the overall number of package dependencies, it should be ultralight in it's own packaging. While that's a valid point, I think a balance is required and using existing well-tested libraries is important.

Something went wrong with that request. Please try again.