Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm getting following error - NPM ERROR : debug module is not working

I need to use debug module to replace my console.log in my node application. I've installed the debug module in my application using following command.

npm install debug

Then I've initialized the debug variable as described below.

const debug = require('debug')('http');
debug('debug information');

but nothing is getting logged in terminal. Any kind of help would be appreciated.

like image 918
Gayan Charith Avatar asked Nov 12 '14 11:11

Gayan Charith


People also ask

How do I resolve npm start error?

To solve the Missing script: "start" error, make sure to add a start command to the scripts object in your package. json file and open your shell or IDE in the root directory of your project before running the npm start command.

How fix npm module not found?

If you have run the npm install command before, then it's possible that the installation of the module is incomplete or corrupted. Delete the node_modules/ folder using the rm -rf node_modules command, then run npm install again. That may fix the issue.

Why my npm is not working?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).


1 Answers

Don't forget to set the DEBUG env variable with a list of debug functions, below an example within the interpreter

~  DEBUG=http node
> var debug = require('debug')('http')
undefined
> debug('Test debug log')
 http Test debug log +0ms
undefined 
like image 75
Aitor Carrera Avatar answered Oct 05 '22 19:10

Aitor Carrera