How to update node modules programmatically
<p>I need to use the <code>npm</code> update from a script. Below is my code:</p>

<pre><code>var npm = require('npm');
npm.load(function () {
npm.commands.outdated({json: true}, function (err, data) {
    //console.log(data);
    npm.commands.update(function(err, d){
        console.log(d);
    });
   });
});
</code></pre>

<p>When I run this script, the modules get updated, but the new versions are not indicated in the package.json.</p>

<p>When I run <code>npm update --save-dev</code>  from command line, folders and package.json get updated.</p>

<p>Please suggest how this can be achieved through the script.
How can I use <code>--save-dev</code> option through code?</p>