apache / apache/cordova-electron
Broken plugin installation
- Dominant language
- JavaScript
- Stars
- 135
- Forks
- 60
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used [patch-package](https://github.com/ds300/patch-package) to patch `cordova-electron@3.0.0` 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. (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
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](https://github.com/ds300/patch-package/issues/296).
Contributor guide
Research direction
Start with lib/handler.js, at the plugin installation path that invokes npm through execa. Reproduce a clean platform installation with a local plugin and conflicting dependency lists, then verify that the installation completes without missing files or module-import errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100