You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug]: With an nx.json config, npx cap sync hooks (capacitor:sync:before and capacitor:sync:after) are executing from the node_modules instead of the repo root
#7606
Open
2 of 3 tasks
gabides opened this issue
Aug 6, 2024
· 2 comments
@capacitor/android: not installed
@capacitor/cli: 6.1.1
@capacitor/core: 6.1.1
@capacitor/ios: 6.1.1
[success] iOS looking great! 👌
Other API Details
npm 9.5.0
node v18.15.0
Platforms Affected
iOS
Android
Web
Current Behavior
This is a follow up to #7581 . Sorry for posting again but I could not manage to create a reproduction repo until now and the issue was closed today so I can't reply there. This comment from de-robat gave me a hint that it was coming from the fact that we are using nx in our repo.
As the reproduction repo suggests below, having an nx.json file inside the project will lead the npx cap sync command to execute at the root of each plugin inside the node_modules (once per plugin) starting with capacitor/cli 6.1.0, whereas:
if you delete nx.json, it executes only once, at the root of the repo
if you keep nx.json and downgrade capacitor/cli to version 6.0.1, it executes only once, at the root of the repo
Expected Behavior
Execute the capacitor:sync:before and capacitor:sync:after hooks only once and at the root of the repo (and not once per plugin inside the node_modules) when using an nx config and when the version of capacitor/cli is 6.1.0 (like it was in previous versions, e.g. 6.0.1)
If this is an intended behaviour, can you provide some documentation for it, or an alternative to prevent it as it is a change in the behaviour of the hooks of the sync command
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.
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 6.1.1
@capacitor/core: 6.1.1
@capacitor/android: 6.1.1
@capacitor/ios: 6.1.1
Installed Dependencies:
@capacitor/android: not installed
@capacitor/cli: 6.1.1
@capacitor/core: 6.1.1
@capacitor/ios: 6.1.1
[success] iOS looking great! 👌
Other API Details
Platforms Affected
Current Behavior
This is a follow up to #7581 . Sorry for posting again but I could not manage to create a reproduction repo until now and the issue was closed today so I can't reply there. This comment from de-robat gave me a hint that it was coming from the fact that we are using nx in our repo.
As the reproduction repo suggests below, having an
nx.json
file inside the project will lead thenpx cap sync
command to execute at the root of each plugin inside the node_modules (once per plugin) starting withcapacitor/cli
6.1.0, whereas:nx.json
, it executes only once, at the root of the reponx.json
and downgradecapacitor/cli
to version 6.0.1, it executes only once, at the root of the repoExpected Behavior
Execute the
capacitor:sync:before
andcapacitor:sync:after
hooks only once and at the root of the repo (and not once per plugin inside the node_modules) when using an nx config and when the version ofcapacitor/cli
is 6.1.0 (like it was in previous versions, e.g. 6.0.1)If this is an intended behaviour, can you provide some documentation for it, or an alternative to prevent it as it is a change in the behaviour of the hooks of the sync command
Project Reproduction
https://github.com/gabides/capacitor-sample-app-sync-issue
Additional Information
the reproduction repo was created:
create-capacitor-app
command linecapacitor:sync:after
hookThe text was updated successfully, but these errors were encountered: