Node.js provides you some packages
out of the box. Some common ones include
The fs (Filesystem) package is used to read, write, update contents on the filesystem.
const fs = require('fs');
const path = require('path');
const filePath = path.join(__dirname, 'a.txt');
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.log(err);
} else {
console.log(data);
}
});
Why use the path
library?
/Users/kirat/Proejcts/../../Projects
to /Users/kirat/Projects