Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

The getting started page for the Express application generator (located here) says to start the server by using $ DEBUG=myapp:* npm start if using MacOS or Linux.

This works fine, but I'm having trouble understanding what this line is actually doing. I would have guessed that it would be assigning something to the variable DEBUG, but after exiting the server I ran echo $DEBUG and it printed nothing. I'm guessing the : is somehow key here, but it's not clear to me how/why.

Hopefully someone can break this down for me.

like image 739
Pak Avatar asked Mar 26 '16 20:03

Pak


1 Answers

  • 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 then followed 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 start enter image description here

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

like image 75
Andrew Lam Avatar answered Oct 13 '22 14:10

Andrew Lam