Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js - How to cross-platform find the 'desktop' directory path?

As mentioned in https://stackoverflow.com/a/32556337/103396, require('os').homedir() is the way to get the user's home directory.

In Windows the desktop path would be on user_home_dir/Desktop:

require('path').join(require('os').homedir(), 'Desktop')

Will this work on other platforms?

like image 571
rtribaldos Avatar asked Apr 24 '17 20:04

rtribaldos


Video Answer


1 Answers

Sorry for the late reply.

Yes, it does work cross-platform. So far, I've tested it on Windows 10 and Ubuntu, both have positive results.

See:

Windows 10 Screenshot

Ubuntu Screenshot

like image 161
Etosticity Avatar answered Nov 15 '22 21:11

Etosticity