electron-vue
electron-vue copied to clipboard
Renderer in built executable cannot find @electron/remote
Found an issue or bug with electron-vue? Tell me all about it!
I am trying to import dialog
in the renderer process.
It works fine when serving directly (electron:serve).
It does not work when building an executable and launching that (electron:build).
It is unclear to me if this is a user error.
Describe the issue / bug.
I am importing like this in my Vue project:
const { dialog } = window.require("@electron/remote");
This works when running with npm run electron:serve
.
It fails to produce a working application when run with npm run electron:build
.
The development console:
internal/modules/cjs/loader.js:887 Uncaught Error: Cannot find module '@electron/remote'
Require stack:
- electron/js2c/renderer_init
at Module._resolveFilename (internal/modules/cjs/loader.js:887)
at Function.o._resolveFilename (electron/js2c/renderer_init.js:33)
at Module._load (internal/modules/cjs/loader.js:732)
at Function.f._load (electron/js2c/asar_bundle.js:5)
at Function.o._load (electron/js2c/renderer_init.js:33)
at Module.require (internal/modules/cjs/loader.js:959)
at require (internal/modules/cjs/helpers.js:88)
at Module.cd49 (App.vue:40)
at o (bootstrap:79)
at Object.0 (app.4ede792c.js:1)
If relevant, here's how the main window is created:
const mainWindow = new BrowserWindow({
// skipping dimensions and title...
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
},
});
How can I reproduce this problem?
Import @electron-remote
like this:
const { dialog } = window.require("@electron/remote");
Run npm run electron:build
.
Run the executable.
Tell me about your development environment.
- Node version: 15.14.0
- NPM version: 6.14.8
- vue-cli version: (if necessary) 4.5.12
- Operating System: Windows 10 x64
Probably an issue with @electron/remote, but I don't see how to bundle it with electron-vue.
@MrManny the same issue with electron-builder package (without vue). maybe the problem is with version of "electron-builder": "^22.10.5" your?
Uncaught Error: Cannot find module '@electron/remote'
Require stack:
- /Applications/TagSpaces.app/Contents/Resources/app.asar/app.html
at Module._resolveFilename (internal/modules/cjs/loader.js:887)
at Function.o._resolveFilename (electron/js2c/renderer_init.js:33)
at Module._load (internal/modules/cjs/loader.js:732)
at Function.f._load (electron/js2c/asar_bundle.js:5)
at Function.o._load (electron/js2c/renderer_init.js:33)
at Module.require (internal/modules/cjs/loader.js:959)
at require (internal/modules/cjs/helpers.js:88)
at new electron_io_ElectronIO (electron-io.ts:67)
at Object.<anonymous> (platform-io.ts:27)
at __webpack_require__ (bootstrap:63)
@MrManny did you manage to solve this?