NODE_ENV=dev node server.js
That is the start
script in my package.json file. So, I start the app with npm start
I want to use the debug
module, but I am unsure how to set multiple environment variables when starting the app as I am above.
How would I add DEBUG=*
to the start script above?
You can simply use:
NODE_ENV=dev DEBUG=* node server.js
and in your package.json file:
{
"name": "yourApp",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "NODE_ENV=dev DEBUG=* node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
...
}
}
The answer is already given but I will add some more detail as I was looking for debugging only request.
To work with express
NODE_ENV=dev DEBUG=express:* node server.js
or
NODE_ENV=dev DEBUG=myapp node server.js
and as mention by @agconti
NODE_ENV=dev DEBUG=* node server.js
To debug particular namespace
NODE_ENV=dev DEBUG=request:* node server.js
You can also exclude particular namespace
By prefixing them with a "-"
character. For example, DEBUG=*,-request:*
would include all debuggers except those starting with "request:".
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