cordova-electron
cordova-electron copied to clipboard
external NPM modules are not loading after building [email protected]
I am using [email protected] which I recently upgraded. I need to use some of the npm modules to work with the main process but after building the application, those modules are not taking but it workes when I do run the application. what would be the possible issue
I seem to be having the same issue. Have you been successful resolving it?
I'm using cordova-electron with Ionic and what happened in my case.
Cordova-Electron is using:
- Two package.json Structure to manage application dependencies. First package.json is located in your base directory and is under my control (source control-wise). The second one is located under ./platforms/electron/www/package.json which is not under my control (and shouldn't be as it will be replaced after every platform add/remove)
- Electron-Builder to bundle and build your application.
After I run "ionic cordova build electron", electron-builder is running npm install (with some flags) behind the scenes, however, it is using dependencies from package.json located in platform/electron/www directory, not the project one. So none of the npm modules is not loaded because they are missing in the package.json file.
Breaking change can be found in this commit: #175 in the PackageJsonParser.js file. A deleted part from lines 42 to 82 was responsible for coping dependencies from your project package.json to electron package.json. I think it was done because of security reasons, as it was done in the same commit where context isolation was enabled and node integration disabled.
any workaround for fixing this issue? @timbru31 @MarBas97 please let me know if there is any alternative way to install any npm package in corodova-electron?