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

Broken plugin installation #211

Open
miroslavvojtus opened this issue Oct 8, 2021 · 1 comment · May be fixed by #212
Open

Broken plugin installation #211

miroslavvojtus opened this issue Oct 8, 2021 · 1 comment · May be fixed by #212

Comments

@miroslavvojtus
Copy link

miroslavvojtus commented Oct 8, 2021

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Without that I observed that quite often (3 of 5) a clean run (platform with plugins readded) of project with local plugin with several frameworks with clashing dependency lists fails on some random error in regards to imports from node modules.
Each time I found some installed packages with missing files.

Sample error:

2021-10-07 17:07:05.078] [error] UncaughtException on origin uncaughtException Error: Cannot find module './utf8'
Require stack:
- D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\platforms\electron\www\node_modules\jszip\lib\object.js
- D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\platforms\electron\www\node_modules\jszip\lib\index.js
- D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\platforms\electron\www\node_modules\unzip-crx-3\dist\index.js
- D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\platforms\electron\www\node_modules\electron-devtools-installer\dist\downloadChromeExtension.js
- D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\platforms\electron\www\node_modules\electron-devtools-installer\dist\index.js
- D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\platforms\electron\www\cdv-electron-main.js
- D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\node_modules\electron\dist\resources\default_app.asar\main.js
- 
    at Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:245:1128)
    at Module._load (internal/modules/cjs/loader.js:737:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:964:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (D:\ACTTool\Meta\projects\App-ACTTool-FrontEnd-TestTool\cordova\platforms\electron\www\node_modules\jszip\lib\object.js:2:12)
    at Module._compile (internal/modules/cjs/loader.js:1083:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1113:10)
    at Module.load (internal/modules/cjs/loader.js:940:32)

The source of problem seems to be asynchroncity of execa.

Here is the diff that solved my problem:

diff --git a/node_modules/cordova-electron/lib/handler.js b/node_modules/cordova-electron/lib/handler.js
index ffa9e80..1b2e5ea 100644
--- a/node_modules/cordova-electron/lib/handler.js
+++ b/node_modules/cordova-electron/lib/handler.js
@@ -117,7 +117,7 @@ module.exports = {
 
             const wwwDir = path.join(project_dir, 'www');
 
-            execa('npm', ['install', electronPluginSrc], {
+            execa.sync('npm', ['install', electronPluginSrc], {
                 cwd: wwwDir
             });
 

This issue body was partially generated by patch-package.

@miroslavvojtus miroslavvojtus linked a pull request Oct 8, 2021 that will close this issue
5 tasks
@goffioul
Copy link

goffioul commented Nov 3, 2021

I have a related problem, but the proposed solution does not fix it.

To reproduce my scenario, you need a plugin that support electron and another platform (I'm using android). The electron part needs to use a framework entry. Then the steps are:

  1. create a new cordova project
  2. add the 2 platforms supported by your plugin
  3. add the plugin
  4. rm -rf platforms plugins
  5. cordova prepare android (use the other platform instead of android if you didn't use android)
  6. cordova prepare electron

The suggested fix does not help, because at that point platforms/electron/www does not exist yet. So the npm command fails. Creating the directory does not help, because package.json would be missing anyway.

If you think this is a different issue, I'm happy to open a separate issue.

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

Successfully merging a pull request may close this issue.

2 participants