Possible to install all missing modules for a node application?

I have a node app that I just started working with and each time I try to run it, it says there is a missing module. I've just been using npm install ... for each module but after doing about 10 of them I'm wondering if there is a way to have npm pull down all needed modules for a node app without me installing each one manually. Can it be done?

Yes, as long as the dependency is listed in package.json.

In the directory that contains package.json, just type:

npm install

I created an npm module to handle installing missing modules automatically.

npm-install-missing

It will install all app dependencies and sub-dependencies automatically. This is useful when submodules aren't installed correctly.

You can run npm install yourModule --save in order to install and automatically update package.json with this newly installed module.

So when you run npm install a second time it will install every dependecy previously added and you won't need to reinstall every dependency one by one.

I writed a script for that. Please add it before the first require function:

(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){
                }
            })
        }
    }
})()