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


#1

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


#2

Found the answer on StackOverflow. Turns out my package.json should be more general, pointing to

"scripts": {
    "start": "electron ."
  }

This resolved the issue for me.