407 Views
To get the extension of a file in Node.js, we can use the extname() method from the path module. For example: const path = require('path'); path.extname('style.css') // .css path.extname('image.png') // .png path.extname('prettier.config.js') // .js The extname() method returns the extension of the given path from the last occurrence of the .
0 comments