19

When I run npm start and there is some error, it says:

npm ERR! Additional logging details can be found in:
npm ERR!     /home/hsz/Projects/project/npm-debug.log
npm ERR! not ok code 0

And this file is located in a directory from which I have called npm.

Is it possible to set npm-debug.log output file to ./logs/npm-debug.log ?

2 Answers 2

5

Update:

npm pull request #6744 tries to move npm-debug.log from cwd into the cache folder.


Original Answer:

There doesn't seem to be a way to do this. It is hardcoded:

In error-handler.js

if (wroteLogFile) {
  log.error("", [""
            ,"Additional logging details can be found in:"
            ,"    " + path.resolve("npm-debug.log")
            ].join("\n"))
  wroteLogFile = false
}
log.error("not ok", "code", code)

And other occurrences as well.

I don't think this flexibility would fit into npm's philosophy see isaacs comment:

npm config set prefix?

If you want to spell "node_modules" differently, sorry, no can do. That's built into node-core. Changing that is tantamount to building a completely different package manager.

2
  • 3
    That comment has nothing to do with the npm-debug.log, changing the node_modules directory location is a whole different story, more accurate discussion: github.com/npm/npm/pull/5252
    – Ian Walter
    Mar 18, 2015 at 3:14
  • Thanks @IanWalter, I've updated my answer, and yes the comment is not directly related. Mar 19, 2015 at 9:25
0

RFC 499

I opened up an RFC 499 to make this request. Please consider upvoting it for visibility or commenting with your own ideas on how this feature should look. This will track the progress and input under the official npm/rfcs project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.