Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change npm-debug.log location

Tags:

node.js

npm

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 ?

like image 369
hsz Avatar asked Feb 07 '14 09:02

hsz


People also ask

How do I view npm debug logs?

To find your . npm directory, use npm config get cache . If you use a CI environment, your logs are likely located elsewhere. For example, in Travis CI, you can find them in the /home/travis/build directory.

Where are npm logs stored in Windows?

NPM logfiles are stored on windows in the following path: C:\Users<user>\AppData\Roaming\npm-cache.

What is npm verbose?

Example usage: npm install ionic --loglevel verbose . Running the npm commands like this, shows the logs in realtime and saves the logs to the directory its running within. For permanent solution, just edit the global npm configuration. To do this, run npm config edit command and add loglevel=verbose .

Where are Nodejs logs stored?

Answer. Note: Node. js can also records logs directly into /var/www/vhosts/system/example.com/logs/ directory, but this functionality is a part of Passenger Enterprise which is not included into the free edition that is provided by Plesk.


1 Answers

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.

like image 138
Omar Al-Ithawi Avatar answered Sep 22 '22 22:09

Omar Al-Ithawi