var path = require('path'); //Extract the filename, but leave the file extension: var filename = path.basename('/Users/Refsnes/demo_path.js', '.js'); console.log(filename);