What does the __dirname variable provide in a Node.js module?

Node.js Developer Easy

Node.js Developer — Easy

What does the __dirname variable provide in a Node.js module?

Key points

  • __dirname gives the exact path of the current module directory
  • It is not the root directory of npm global packages or the directory where Node.js is installed
  • Helps in accessing files within the same module or directory

Ready to go further?

Related questions