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.
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.
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.
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).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With