I am trying to use npm install debug
in my node server.
var debugModule = require('debug');
var debugMainApp = debugModule('debugMainApp')
const express = require('express');
const app = express();
const port ='3000';
const domain = 'localhost';
app.listen(port,domain,()=>{
debugMainApp('Server started in port: ' + port + ' hostname: ' + domain);
});
debugMainApp('Server started in port: ' + port + ' hostname: ' + domain);
is not printing anything to console.
My attempts to solve this issue
By setting the attribute debugMain.enabled = true
manually debugMainApp('Server started in port: ' + port + ' hostname: ' + domain);
printed the following into console:
mainApp Server started in port: 3000 hostname: localhost +0ms
To my understanding this debugMain.enabled
attribute should be set automatically when an environment variable that matches the string debugModule('this_String')
is set.
Here is how I set the environment variable and start my server
$ DEBUG=debugMainApp & node server.js
But it seems that the latter is not setting the environment variable properly.
Questions
- If you think my environment variable theory is right. What is the correct way to set an environment variable using a GitBash command line? e.g.
$ DEBUG=mainApp & node server.js
- Could it be something else?
Thanks in advance.
More relevant info:
My OS: Windows 10
GitBash Version: 2.13.0.windows.1
NodeJS version: 6.10.3