How to get the current filename extension in Node.js

2 Answers

0 votes
const path = require('path');

console.log(path.extname(__filename));


     
/*
run:
   
.js

 
*/

 



answered Mar 9, 2020 by avibootz
0 votes
const path = require('path');

console.log(path.parse(__filename).ext);


     
/*
run:
   
.js
 
*/

 



answered Mar 9, 2020 by avibootz

Related questions

3 answers 528 views
1 answer 330 views
4 answers 653 views
1 answer 302 views
1 answer 319 views
1 answer 277 views
1 answer 326 views
...