Install lazy dependencies when your node.js app starts. Modules are cached and shared between projects for blazing fast installs.
$ npm install --save lazy-install
// package.json
{
"name": "myProject",
"lazyDependencies": {
"server": {
"express": "4.0.0"
},
"test": {
"mocha": "1.18.2"
}
}
}
var lazy = require("lazy-install");
Install all lazy dependencies in package.json
function callback (err, installed) {
if (err) throw new Error(err);
console.log(installed.count, installed.time);
}
lazy.install(callback);
Install app dependencies, and optionally test dependencies
var groups = ['server'];
if (process.env.ENV !== 'production') groups.push('test');
lazy.install({
'groups': groups
}, callback);
Make runtime decisions on what to install
lazy.install({
'before': function (name, version) {
if (name[0] !== 'ex') return false;
return true;
}
}, callback);
Load another json file and install modules relative to its parent folder. Could be useful for when including components as git submodules.
lazy.install({
'path': process.cwd() + '/components/foo/package.json'
}, callback);
- 0.3.0 Stores cached module in a shared folder, in
$HOME/.lazy-install-cache
, for even faster installs when using lazy-install in multiple projects #4 - 0.2.3 Fixed issue with the cache path
- 0.2.2 Fixed critical bug in
lib/copy
- 0.2.1 Improved result logging, separating
result.count
andresult.cached
- 0.2.0 Cache modules in
/cache
for blazing fast re-installs - 0.1.0 Initial release
Made by Adam Renklint, Berlin 2014. MIT licensed.