To get folder path from a file with Node.js, we call the path.dirname
method.
For instance, we write
const path = require("path");
const dir = path.dirname("G:\\node-demos\\7-node-module\\demo\\config.json");
to call path.dirname
to return the folder path for the "G:\\node-demos\\7-node-module\\demo\\config.json"
path.