npm将所有日志安装输出到标准错误stream

我正在尝试正确logging,包括正在执行npm安装的方式。 但是,npm将其所有日志logging到错误stream,所以我的应用程序日志loggingfunction始终显示这些日志是错误的,但不是。 有没有办法将npm设置为使用console.log而不是console.error?

以编程方式使用npm,以便您可以覆盖默认error handling程序。 如自述文件和npm cli界面的源代码所示 :

var npm = require('npm'); (...) // now actually fire up npm and run the command. // this is how to use npm programmatically: npm.load(conf, function (er) { if (er) return errorHandler(er) npm.commands[npm.command](npm.argv, errorHandler) })