title: node.js - how to get the OS platforms user data folder
body: <p>I am looking for a way to get the userdata folder using Node.js, that will work on both Windows and macOS.</p>
  
  <p>The Node.js instance would be running on the user's machine.</p>
  
  <p>I need something that returns the following:</p>
  
  <ul>
  <li><code>C:\Documents and Settings\JohnD\Application Data</code> <em>(Windows XP)</em></li>
  <li><code>C:\Users\JohnD\AppData\Roaming</code> <em>(Windows Vista and Up)</em></li>
  <li><code>/Users/JohnD/Library/Preferences</code> <em>(macOS)</em></li>
  </ul>
  
  <p>Is this possible?</p>