Node.js Built-In Modules
In the previous section, we extensively went over the
events module and learned everything about using events to achieve easy communication within our applications. The
events module is a built-in module offered by Node.js, meaning that we do not need to use
npm to install it. In this module, we will discuss how to use the
path module is a built-in module that provides utilities that can help us work with file paths and filenames.
Path.join() is a very useful function when we are working with directories and files in our applications. It allows us to join paths together and output a path string that we can use in the fs module. To use
join paths, we can call the
join method and provide it with a list of paths. Let's look at the following example:
const currentDir = '/usr/home/me/Documents/project'; const dataDir = './data'; const assetDir = './assets&apos...