Bootstrap FreeKB - Node.js - Return and print script name
Node.js - Return and print script name

Updated:   |  Node.js articles

__filename is a built in Node.js variable to return the name of a file. Often this is used to return the name of the Node.js script you are running.

console.log(`scriptname = ${__filename}`)

 

Which should print something like this.

scriptname = app.js

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 853d3b in the box below so that we can be sure you are a human.