Resolve the absolute path from a relative or OS-specific path
npm i pathabs
import pathabs from "pathabs";
const pathabs = require("pathabs");
let filePath = "~/Documents/GitHub";
// "~/Documents/GitHub"
console.log(filePath);
filePath = pathabs(filePath);
// "/home/{USER_NAME}/Documents/GitHub" on Linux
// "C:\Users\{USER_NAME}\Documents\GitHub" on Windows
console.log(filePath);