Node.js - Return and print script name

by
Jeremy Canfield |
Updated: November 25 2024
| 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