Hello! Im trying to build an app using Ionic 4 that connects to Stellar blockchain network. In order to do so I import js-stellar-sdk into my Ionic app.
I can use “ionic serve” and everything works fine, but when I try to test the app with an android emulator using “ionic cordova run android” or “ionic cordova build android” I get the error:
Error
ERROR in ./node_modules/eventsource/lib/eventsource.js
Module not found: Error: Can't resolve 'http' in 'C:\Users\Rafael Cisneros\Desktop\Work\Ionic\StellarTest\node_modules\eventsource\lib' ERROR in ./node_modules/eventsource/lib/eventsource.js
Module not found: Error: Can't resolve 'https' in 'C:\Users\Rafael Cisneros\Desktop\Work\Ionic\StellarTest\node_modules\eventsource\lib'
[ERROR] An error occurred while running subprocess ng.
If I comment the line where I use stellar, build runs successfully:
this.server = new Server('https://horizon-testnet.stellar.org');
I pushed it into a repo:
Ionic info
These are the versions im using:
Ionic:
- Ionic CLI : 5.2.3 (C:\Users\Rafael Cisneros\AppData\Roaming\npm\node_modules\ionic)
- Ionic Framework : @ionic/angular 4.7.4
- @angular-devkit/build-angular : 0.802.0
- @angular-devkit/schematics : 8.2.0
- @angular/cli : 8.2.0
- @ionic/angular-toolkit : 2.0.0
Cordova:
- Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
- Cordova Platforms : not available
- Cordova Plugins : not available
Utility:
- cordova-res : not installed
- native-run : 0.2.8
System:
- Android SDK Tools : 26.1.1 (C:\Users\Rafael Cisneros\AppData\Local\Android\Sdk)
- NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
- npm : 6.9.0
- OS : Windows 10
Thanks for the help!