Node Use npm Programmatically
You can use npm
from one of your applications, programmatically, as mentioned in the documentation.
The example they provide:
var npm = require("npm")
npm.load(myConfigObject, function (er) {
if (er) return handlError(er)
npm.commands.install(["some", "args"], function (er, data) {
if (er) return commandFailed(er)
// command succeeded, and data might have some info
})
npm.registry.log.on("log", function (message) { .... })
})
You cannot set configs individually for any single npm function at this time. Since npm is a singleton, any call to npm.config.set will change the value for all npm commands in that process.