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 352 views
1 answer 223 views
4 answers 444 views
1 answer 214 views
1 answer 216 views
1 answer 181 views
1 answer 238 views
...