lazy-require

Lazy require allows you to require modules lazily, meaning that when you lazy require a missing module, it is automatically installed. If the installation or require fails, the error is returned to the lazy require callback.

npm install lazy-require
90 downloads in the last day
507 downloads in the last week
3 039 downloads in the last month

Lazy Require

Build Status NPM version Flattr this project

Lazy require allows you to require modules lazily, meaning that when you lazy require a missing module, it is automatically installed. If the installation or require fails, the error is returned to the lazy require callback.

Install

  1. Install Node.js
  2. npm install --save lazy-require

Usage

// Import
var lazyRequire = require('lazy-require').lazyRequire;

// Load a module lazily
lazyRequire('iconv', function(err,iconv){
    // Check
    if (err)  return console.log('iconv failed to load because of:', err.stack);

    // Success
    // iconv....
});

History

You can discover the history inside the History.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd

npm loves you