0

I have an src/starter.js file

that has

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

etc that creates in the app window.

In src/another.js file I am trying to get the app.getAppPath("temp") path. I've tried export app export { app }, export const tempPath = app.getAppPath("temp") and importing those in the another.js file but nothing seems to work. How should I be able access these from another.js file?

  • if you export anything not related to the app, does it work? in other words: app needs initialization, it might not have the info yet or maybe you aren't exporting/importing correctly – Willyfrog May 28 '20 at 13:15
  • 1
    are you using ES modules? have you tried `module.exports = { app }` then importing it via `const { app } = require('./otherfile')`? If you're using webpack/babel you should just be able to do `import { app } from 'electron'` – KFE May 28 '20 at 13:18
  • The app initialises fine, and creates the window etc. If I try to export I get 'unexpected token export', or if I try those from KFE then the app still initialises but then all the UI is gone and I get 'Uncaught TypeError: r.existsSync is not a function' from index.js – asparamancer May 28 '20 at 13:54
  • given your error I'd take a look at: https://stackoverflow.com/questions/38296667/getting-unexpected-token-export – Willyfrog May 29 '20 at 09:30

0 Answers0