Skip to content

Instantly share code, notes, and snippets.

@potato4d
Last active August 24, 2016 10:34
Show Gist options
  • Select an option

  • Save potato4d/fd7ff6e3a05d268269ea18ac71dcddc4 to your computer and use it in GitHub Desktop.

Select an option

Save potato4d/fd7ff6e3a05d268269ea18ac71dcddc4 to your computer and use it in GitHub Desktop.
Node.jsでユーザーのホームディレクトリのパスを取得する ref: http://qiita.com/potato4d/items/7131028497de53ceb48e
const path = require("path");
const userHome = process.env[process.platform == "win32" ? "USERPROFILE" : "HOME"];
console.log(path.join(userHome, "Desktop"));
// /Users/foo/Desktop
console.log(path.join(userHome, "Documents"));
// /Users/foo/Documents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment