How to Get the Extension of a File in Node.js

added by JavaScript Kicks
10/5/2022 4:04:12 PM

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