Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Buffer not defined [Angular 8] #392

Closed
Jeroen96 opened this issue Aug 13, 2019 · 4 comments
Closed

Buffer not defined [Angular 8] #392

Jeroen96 opened this issue Aug 13, 2019 · 4 comments

Comments

@Jeroen96
Copy link

Hi,

I'm trying to get the ledger libs to work with Angular 7/8. I've tried with the ../hw-transport-u2f first but i get the regeneratorRuntime error (#332). Using the recommended hw-transport-webusb results in a Buffer not defined error. This error also shows up after 'fixing' the regenerator with babel-polyfill when using the u2f lib.

image

This error is generated in a fresh Angular 8.2.0 project.

only code being called is (structure omitted for readability):

import TransportWebUSB from '@ledgerhq/hw-transport-webusb';
if (TransportWebUSB.isSupported()) {

    }
@meriadec
Copy link
Member

looks like you need a Buffer polyfill (module bundlers like webpack does that automatically). check this or this.

@aleffabricio
Copy link

aleffabricio commented Aug 22, 2019

Hello @Jeroen96 , I solved this problem Angular 8 by placing in the polyfills.ts file:

(window as any).global = window;
window.Buffer = window.Buffer || require('buffer').Buffer;

must contain the installed buffer library: https://www.npmjs.com/package/buffer

@noedadon
Copy link

That doesn't work :

ERROR in src/app/app.component.ts(13,16): error TS2339: Property 'Buffer' does not exist on type 'Window'.
src/app/app.component.ts(13,32): error TS2339: Property 'Buffer' does not exist on type 'Window'.

@aleffabricio
Copy link

Isso não funciona:

ERRO no src / app / app.component.ts (13,16): erro TS2339: A propriedade 'Buffer' não existe no tipo 'Window'.
src / app / app.component.ts (13,32): erro TS2339: A propriedade 'Buffer' não existe no tipo 'Window'.

Hello @magicsign, in which version did you install the buffer library? mine is at 5.4.2 and I noticed that the library was recently updated to 5.5.0 and I haven't tested this version yet. Version 5.4.2 still works normally for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants