What is the use of __dirname and __filename?
- __dirname: Returns the directory path of the current module.
- __filename: Returns the full file path of the current module.
π Example:
console.log(__dirname); // /Users/yourname/project
console.log(__filename); // /Users/yourname/project/app.js
These are very useful for reading or writing files relative to the script's location.
PM and Module Management