1

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 1

4

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);
    });
}
2
  • Being a node.js newbie, I had to install the request module using "npm install request" before it would work
    – John Carse
    Mar 20, 2012 at 14:45
  • http://registry.npmjs.org/-/all is incorrect.
    – Hajitsu
    May 8, 2019 at 12:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .