When I run require('os').homedir()
from an electron (4.0.1) app I get /
, but if I run it from node directly I get my home directory:
node --version
v10.14.1
node
> require('os').homedir()
'/Users/myusername'
>
Any idea why?
Electron has an API for this:
https://electronjs.org/docs/api/app#appgetpathname
const {app} = require('electron');
app.getPath('home');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With