How can I tell npm to install all packages available in its repository? I have to work offline, so I'm preparing a virtual machine to code in node.js and I don't know if I may end up needing some package in the future, so I wish I was able to install all of them beforehand.
1 Answer
A list of all packages can be found here http://registry.npmjs.org/-/all
var request = require('request');
var exec = require('child_process').exec;
request('http://registry.npmjs.org/-/all', function(err, request, body) {
install(Object.keys(JSON.parse(body)));
});
function install(packages) {
var pkg = packages.shift();
console.log('installing ' + pkg + '...');
exec('npm install ' + pkg + ' -g', function() {
if (packages.length)
install(packages);
});
}
-
Being a node.js newbie, I had to install the request module using "npm install request" before it would work Mar 20, 2012 at 14:45
-