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 344 views
1 answer 216 views
4 answers 421 views
1 answer 207 views
1 answer 205 views
1 answer 169 views
1 answer 233 views
...