Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get user home directory with electron

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?

like image 945
Komo Avatar asked Jan 26 '19 17:01

Komo


1 Answers

Electron has an API for this:

https://electronjs.org/docs/api/app#appgetpathname

const {app} = require('electron');
app.getPath('home');
like image 114
customcommander Avatar answered Sep 22 '22 12:09

customcommander