I'm trying to get node into other .js files, other than just index.js. I can only run require() in index.js, and that's not useful when trying to use electron-prompt. any help?
Asked
Active
Viewed 41 times
1 Answers
0
In the future, providing the specific packages you want to use might allow for a more specific fix, however, as a general overview.
In electron you can change the node integration settings when you create your browser window using the code block below. This isn't recommended as it poses a security risk when running remote code. If you don't care about security(which you should) you can go ahead and use this.
app.on('ready', () => {
mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
}
});
});
If you do care about security, I would check out the second answer to this post: Electron require() is not defined

Dacoolinus
- 388
- 1
- 10