Our team is currently working on developing an app that will interact with the Horizon Stellar Server. As newcomers in this area, we are exploring the use of Angular 8 and Ionic 4 frameworks. However, we have encountered difficulties when trying to import the js-stellar-sdk successfully. A new app was created for testing purposes, but unfortunately, it fails to compile.
We attempted the following workaround: However, we faced errors stating "StellarSdk is not defined" and "Server is not a constructor/function" even after commenting out the declaration.
Further investigation led us to this link: https://github.com/stellar/js-stellar-base/issues/128 Where it was mentioned that the issue had already been resolved as per: https://github.com/stellar/js-stellar-base/issues/128#issuecomment-474474028 We wanted to follow the suggestions provided here: https://github.com/stellar/js-stellar-base/issues/128#issuecomment-391374590 However, it appears that the solution may no longer be applicable in Angular 8 (unsure if manual creation is required).
This snippet shows our app.component.ts file:
import { Component, OnInit } from '@angular/core';
import { Server } from 'stellar-sdk';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
title = 'example';
server: any;
ngOnInit(): void{
this.server = new Server('https://horizon.stellar.org');
}
}
The error message received is as follows:
ERROR in ./node_modules/eventsource/lib/eventsource.js Module not found: Error: Can't resolve 'http' in 'C:\Users\Rafael Cisneros\Desktop\Work\Ionic\example\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\example\node_modules\eventsource\lib'