node get absolute path 1

node get absolute path

// to get a valid absolute path
resolve = require('path').resolve

// to get current file directory

Here is what the above code is Doing:
1. The first line is a shebang. It tells the shell what program to use to run the script.
2. The second line is a comment. It’s ignored by the interpreter.
3. The third line imports the path module from the Node.js standard library.
4. The fourth line calls the resolve function from the path module.
5. The fifth line calls the resolve function again.
6. The sixth line gets the directory name of the current file.

Similar Posts