angularwebusbledgerjs

Nano Ledger S in Angular


Today I ran into a problem while trying to connect my NANO Ledger S to my angular app.

I've tried installing this package yet it does not seem to work due to the package throwing some errors.

Module '"events"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

This can be fixed by putting changing the EventEmmiter import to

import {EventEmitter} from "events";

Now at least the app compiles, but when I to access the Devices over the TransportWebUSB class a "ERROR Error: Uncaught (in promise): ReferenceError: Buffer is not defined ReferenceError: Buffer is not defined" error is thrown in the console.

I've tried different stuff like following this tutorial and adding

new webpack.ProvidePlugin({
  Buffer: ['buffer', 'Buffer'],
})

this custom Plugin (idk, thats what the internet told be).

I have tried everything I so StackOverflow is my last resort. Thanks for the answers!


Solution

  • So, after a while of testing stuff and even switching to another Hardware-Wallet, I finally got it working.

    I installed the buffer package and in the polyfill.ts I added following lines:

    let Buffer: any = require('buffer/').Buffer;
    (window as any).Buffer = Buffer;
    

    It feels like the biggest hotfix in my life, but at least it works now