Node js Get folder path from a file
use path.dirname
// onlyPath should be G:\node-demos\7-handlebars-watch\demo
var onlyPath = require('path').dirname('G:\\node-demos\\7-node-module\\demo\\config.json');
Simply install path
module and use it,
var path = require('path');
path.dirname('G:\\node-demos\\7-node-module\\demo\\config.json')
// Returns: 'G:\node-demos\7-node-module\demo'