Posts

Showing posts from August, 2020
Image
Quick Intro to Path module - Node.js   The path module provides a way to work with files and directory path. We'll go through some basic and common methods of path module. So let's get started. To start working with path module, first you need to require the path module. path.dirname() This method allows you to get the directory name of  a given path. It does not return the last part of the given path. path.basename() This method  returns  the last part of a given path. If you only want the filename and not the extension,  add the file extension as the second argument in the method. path.extname() This method returns the extension of the path from the last part of the path.  If there is no .  (period) in the last portion of the path, then an empty string is returned. path.normalize() This method normalize the given path, by resolving ' .. ', ' . ' etc. If multiple slashes are found they are replaced by a single slash. path.join() This method joins all the given