This feels so good. lib/utils/log.js is the worst kind of glue code that keeps the npm project from being properly abstracted into independent pieces. In the process, also cleaned up a lot of unproductive logging, and made the npm-debug.log generated on errors be a bit more easy to read.
I think this is why the npm cache gets corrupted so often. If there's a failure while another package is in the process of downloading, then it'll result in a corrupted tarball. Instead, just set the exitCode, and only actually exit with tht code when the 'exit' event occurs, so that in-transit jobs are not forcibly killed.