Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App.getPath("userData") seems to give the wrong path

I have a simple app which is based off electron-quick-start with almost no changes. I'm trying to use nedb and pass it in my userData path.

My Package.json

  "name": "my-electron-app",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  "main": "main.js",
  "scripts": {
    "start": "electron main.js"
  }

My renderer script (app.js):

const remote = require('electron').remote;
const app = remote.app;

console.log(app.getPath('userData'))

According to console, userData is

C:\Users\me\AppData\Roaming\Electron

Shouldn't it be this?

C:\Users\me\AppData\Roaming\my-electron-app

like image 253
roryok Avatar asked Feb 25 '16 15:02

roryok


1 Answers

I believe the issue is that you're pointing Electron to your script directly, meaning Electron is ignoring the existence of your package.json file entirely. Thus it does not know the name of your app.

Try:

"scripts": {
  "start": "electron ."
}
like image 92
Teak Avatar answered Oct 20 '22 05:10

Teak