path Module
path.join, resolve, basename, extname and dirname build and read file paths without string tricks.
Example
const path = require("path");
console.log(path.join("a", "b", "../c.txt"));
console.log(path.basename("/x/y/file.txt"), path.extname("f.tar.gz"), path.dirname("/x/y/file.txt"));
console.log(path.parse("/home/ada/app.js").name);Result
a/c.txt file.txt .gz /x/y app
Exercise
Join parts.
path.("a", "b")
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.