1

Anybody here who had been successful in using the stellar-sdk in angular without any error? I am getting - cannot read property crc16xmodem error - anybody encountered this before?

  • 1
    Thanks for your question. If you don't get a good response, consider updating your question with an MCVE. stackoverflow.com/help/mcve – Synesso Jul 22 '18 at 8:42
  • Which version of Angular? I'm using it on projects running 4, 5, and 6. Let me know and I'll answer with the correct configuration steps (it's different on each...). – Richard Dunn Jul 22 '18 at 15:50
3

As others have mentioned, it sounds like a conflict rather than an import issue. That said, I'm fairly certain I've seen that error before, a long time ago, and I have not used node-crc.

For Angular 6, I use the following configuration:

After installing, you need to add it to angular.json under:

  "architect": {
    "build": {
        "scripts": [
            "./node_modules/stellar-sdk/dist/stellar-sdk.min.js"
        ]

In my StellarService class, I import using:

import * as StellarSdk from 'stellar-sdk/dist/stellar-sdk.min.js';

declare const StellarSdk: any;

@Injectable()
export class StellarService {

    private server: any;

    constructor() {
        this.server = new StellarSdk.Server('https://horizon.stellar.org');
        StellarSdk.Network.usePublicNetwork();
    }

For Angular 5, in your .angular-cli.json:

  "apps": [
    {
      "scripts": [
          "../node_modules/stellar-sdk/dist/stellar-sdk.min.js"
      ]

Class import is the same as Angular 6.

For Angular 4:

Same as 5, except I'm fairly certain I had to add a typings.d.ts file under /src and in it I had to declare:

declare var StellarSdk: any;
0

This sounds like a dependency conflict.

There is another project that had this (or a similar) problem. They solved it by removing their dependency on node-crc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.