Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

external NPM modules are not loading after building [email protected] #216

Open
NishilSB opened this issue Nov 25, 2021 · 3 comments
Open

Comments

@NishilSB
Copy link

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

@NishilSB NishilSB changed the title external NPM modules are no loading after building [email protected] external NPM modules are not loading after building [email protected] Nov 25, 2021
@timbru31 timbru31 transferred this issue from apache/cordova Nov 25, 2021
@weeks6
Copy link

weeks6 commented Mar 29, 2022

I seem to be having the same issue. Have you been successful resolving it?

@MarBas97
Copy link

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.

@NishilSB NishilSB closed this as completed May 6, 2022
@NishilSB NishilSB reopened this May 6, 2022
@NishilSB
Copy link
Author

NishilSB commented May 6, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants