Can't use app module in render process


I have var app = require('app'); in my render process but I keep getting this error “Uncaught Error: Cannot find module ‘app’”.

Is the app module available in the render process or is it limited to only being used in the main process?

The reason I am using the app module is because I want to use app.getPath(userData); so I can work with my config file. I read Electron App Database File Structure/Code Structure and it looks like I should be trying to keep as much out of the main process as possible. Maybe I am missing something?


According to the documentation here:

app is only available to the main process.


Makes sense from a security standpoint.

Thanks for the quick response!


You can use the remote module like so:

var remote = require('remote')
var app = remote.require('app')


Now you have to do:

const {app} = require('electron')
const {BrowserWindow} = require('electron')


const {app} = require(‘electron’).remote;
var userDataPath = app.getPath(‘userData’);

// Example userDataPath: “/Users/name/Library/Application Support/Electron”