capacitor
capacitor copied to clipboard
bug: TypeError: undefined is not a constructor (evaluating 'new cap.Exception('')')
Bug Report
Capacitor Version
@capacitor/cli: 3.6.0
@capacitor/core: 3.6.0
@capacitor/android: 3.6.0
@capacitor/ios: 3.6.0
Current Behavior
I have installed a plugin that should throw an error but failed at it because cap.Exception
is undefined.
TypeError: undefined is not a constructor (evaluating 'new cap.Exception('')') @capacitor/ios#native-bridge.js#L406
After some investigation I found out that cap.Exception
is set in createCapacitor() of @capacitor/core
.
So I added the following to my application and the error disappeared :
import '@capacitor/core';
Expected Behavior
I don't know whether this should be considered as a bug or not, but it certainly was not trivial to find.
I had npm installed
the @capacitor/core
package but did not imported it as I don't needed it.
So in this particular case, should I be the one to import it ? or should it be the plugin somehow ? to make sure it is not forgotten.
Can you guys please give me your thoughts on this ? Thanks!
Code reproduction
- Checkout https://github.com/Badisi/capacitor-exception-issue
-
npm install
-
npx cap run ios
- Inspect the simulator through a web console
Other Technical Details
npm --version
output: 8.13.2
node --version
output: v16.14.2
pod --version
output (iOS issues only): 1.11.2
This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.
Please see the Contributing Guide for how to create a Code Reproduction.
Thanks! Ionitron 💙
@jcesarmobile, I have added a code reproduction section, thanks.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.