String.prototype.replace() with a regular expression and os.homedir() to replace the ~ in the start of the path with the home directory.const untildify = str =>
str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`);
untildify('~/node'); // '/Users/aUser/node'
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️