Explanation for what 'DEBUG=myapp:* npm start' is actually doing
DEBUG=myapp:* npm start
consist of two parts.The first part is
DEBUG=myapp:*
and the second part isnpm start
You may run
DEBUG=myapp:*
first in your command-line tool, and thenfollowed by runningnpm start
.DEBUG=myapp:*
means you are telling nodejs that you want to turn on logging for debugging purposes.- Remember to replace
myapp
with your app name. You can find your app name in package.json file under"name"
property. - The
*
inmyapp:*
means to see all the internal logs used in Express - If you only want to see the logs from the router implementation, then set the value of DEBUG to
myapp:router
. Likewise, to see logs only from the application implementation set the value of DEBUG tomyapp:application
, and so on.
- Remember to replace
npm start
is telling npm to run yourscripts
stated in the package.json file and the script name is calledstart
DEBUG
is set as an environment variable for npm
and sub processes but not set in your shell, consider this:
HELLO=World bash -c 'echo $HELLO' # WorldHELLO=World bash -c "bash -c 'echo \$HELLO'" # Worldecho $HELLO # Nothing, assuming that HELLO was null before running the above snippets
In your case the value myapp:*
gets assigned to the variable DEBUG
. And this variable will be available inside npm
, for what reason it's needed I cannot answer.
This is a temporary assignment; npm
sees the assigned value in its environment, but it does not affect the current shell. DEBUG
retains whatever value it had (or remains unset) after npm
exits.