0

I am trying to use the debug NPM module in conjuction with my express js app. However, when i try to create the environment variable and run the app, I do not receive any of the debug logs!

    var express = require("express");
var chalk = require("chalk");
var debug = require("debug")("app");

var app = express();

app.get("/", function(req, res) {
    res.send("Hello from my library app! ");
});

app.listen(3000, function() {
    debug(`Listening on port ${chalk.green("3000")}. `);
});

I am running windows and am trying the following command in the terminal inside my project directory: set DEBUG=* & node app.js

When i execute this command, the site works - but i do not get any logs atall!

1 Answer 1

1

Have you tried telling debug to use HTTP instead of app

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

Express uses http in the back end and I assume it needs HTTP to be called

Edit: My mistake the (http) part is only namespace

To fix this I added

debug.enabled = true;

This seemed to fix it

Sign up to request clarification or add additional context in comments.

2 Comments

Just tried this and i received the same output as before
I just updated my answer with the working solution. You can add that line any where after you require debug module

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.