Explanation for what 'DEBUG=myapp:* npm start' is actually doing Explanation for what 'DEBUG=myapp:* npm start' is actually doing bash bash

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 is npm start

  • You may run DEBUG=myapp:* first in your command-line tool, and thenfollowed by running npm 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.enter image description here
    • The * in myapp:* 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 to myapp:application, and so on.
  • npm start is telling npm to run your scripts stated in the package.json file and the script name is called startenter image description here

  • Source: https://expressjs.com/en/guide/debugging.html


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.