node.js – how to get the OS platforms user data folder

Try the following:

process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share")

The expected result is:

OS X – ‘/Users/user/Library/Preferences’

Windows 8 – ‘C:\Users\user\AppData\Roaming’

Windows XP – ‘C:\Documents and Settings\user\Application Data’

Linux – ‘/home/user/.local/share’

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)