Created
October 22, 2014 10:31
-
-
Save wmakeev/ccb9b771f7ca7a3304ba to your computer and use it in GitHub Desktop.
Setup unknown npm package on require
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var r=require; | |
require=function (n){ | |
try{ | |
return r(n); | |
} | |
catch(e){ | |
r('child_process').exec('npm i ' + n,function (err,body){ | |
try{ | |
console.log('Module "' +n + '"" not found, try to install. Please restart the app\n' + body ); | |
return r(n); | |
} | |
catch(e){ | |
} | |
}); | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment