Open richardliebmann opened 1 year ago
Workaround: Add following scripts to the package.json/script section in the root folder:
"capacitor:add": "node dist/cli-scripts/cap-scripts.js add",
"capacitor:copy": "node dist/cli-scripts/cap-scripts.js copy",
"capacitor:update": "node dist/cli-scripts/cap-scripts.js update",
"capacitor:sync": "node dist/cli-scripts/cap-scripts.js sync",
"capacitor:open": "node dist/cli-scripts/cap-scripts.js open"
This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. Please see the Contributing Guide for how to create a Sample App. Thanks! Ionitron 💙
Sample app with reproduction added (https://github.com/richardliebmann/capacitor-electron-platform-command-problem)
This issue has been labeled as type: bug
. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.
I ran into the exact same issue.
Bug Report
Capacitor Version
Platform(s)
Current Behavior
capacitor commands for non default platforms are not executed
Expected Behavior
commands should be executed
Code Reproduction
Example Code Base: https://github.com/richardliebmann/capacitor-electron-platform-command-problem
The command does nothing
Code cause:
For non default platforms (isValidPlatform) capacitor searches for the platformDir and find it unter node_modules (e.g. "D:\Repos\andi-ui\node_modules\@capacitor-community\electron"). Code: https://github.com/ionic-team/capacitor/blob/e50e56c5231f230497d1bd420e02e2e065c38f86/cli/src/tasks/add.ts#L45-L70
The runPlatformHook checks if we are in a nx monorepo and overrides the package.json path to the project root folder (D:\Repos\andi-u) instead of the platform root folder (D:\Repos\andi-ui\node_modules\@capacitor-community\electron).
https://github.com/ionic-team/capacitor/blob/e50e56c5231f230497d1bd420e02e2e065c38f86/cli/src/common.ts#L165-L200
The required hook (capacitor:add) defined in the script section of the package.json of the platform therefor is not found in the project root package.json.
The code change was done with feat.Better support monorepos #6811
Other Technical Details
npm --version
output: 8.17.0node --version
output: v18.16.1pod --version
output (iOS issues only):Additional Context