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.

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.

  1. Install Node.js
  2. npm install --save lazy-require
// 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.... 
});

You can discover the history inside the History.md file

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