Reputation: 2138
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?
Upvotes: 11
Views: 12494
Reputation: 18901
Electron has an API for this:
https://www.electronjs.org/docs/latest/api/app#appgetpathname
const {app} = require('electron');
app.getPath('home');
Upvotes: 24
Reputation: 693
my solution from UI render
import { remote } from 'electron'
let userHomePath = remote.app.getPath('home');
Upvotes: 0