Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid `npm-debug.log` creation

Tags:

npm

logging

I run my testing script with npm run test and added {script: {test: "jasmine"}} to the package.json. My problem that every time I run the test, npm generates an npm-debug.log file, which I don't need. Is there a way to turn off this feature?

note:

I will use npm run only by running the tests on http://travis-ci.org/ if it is not possible to turn off this feature, will it generate a log file on the travis server by testing the build, or what?

news 2016:

There are news in the topic. At least after 5 years npm debug log was moved to the cache folder: https://github.com/npm/npm/issues/1548 , so it no longer pollutes our project folders.

like image 982
inf3rno Avatar asked Feb 12 '15 23:02

inf3rno


2 Answers

Sort of good news, eveyone! You can suppress them by setting a command line parameter -loglevel silent, like npm install sfdfsdf -loglevel silent. However, this will also turn off feedback in the console, so I wouldn't do that.

I recommend ignoring them in your .gitignore file, so that they aren't officially in your project. Then, I just pretend they aren't there bothering my obsessive mind. =D

npm config docs. GitHub discussion about this issue.

like image 123
m59 Avatar answered Sep 21 '22 07:09

m59


In addition to m59's answer, you could modify your npm run test to include && rm npm-debug.log. This will automatically delete the log after the test is finished, basically never letting you see it.

like image 45
Florian Wendelborn Avatar answered Sep 22 '22 07:09

Florian Wendelborn