Use path.basename
to get the filename without the .js
extension:
// file.js
const path = require('path');
path.basename('foo.js', '.js'); // foo
path.basename('foo/bar.js', '.js'); // bar
path.basename(__filename, '.js'); // file
Use path.basename
to get the filename without the .js
extension:
// file.js
const path = require('path');
path.basename('foo.js', '.js'); // foo
path.basename('foo/bar.js', '.js'); // bar
path.basename(__filename, '.js'); // file
Please support this site and join our Discord!