Tuesday, 2 October 2018

node.js: __dirname: Get the directory name of current module

‘__dirname’ returns the directory name of the current module.

HelloWorld.js
console.log("HelloWorld.js fiel is located at %s", __dirname);
console.log("HelloWorld.js file absolute path %s",__filename);

Output
HelloWorld.js fiel is located at C:\Users\krishna\Documents\nodejs\examples
HelloWorld.js file absolute path
C:\Users\krishna\Documents\nodejs\examples\HelloWorld.js




Previous                                                 Next                                                 Home

No comments:

Post a Comment