base64url icon indicating copy to clipboard operation
base64url copied to clipboard

Buffer is not defined

Open ramila opened this issue 6 years ago • 14 comments

we recently upgraded our application to angular 6 and RxJs 6. Now I get the following error when trying to encode/decode

Uncaught ReferenceError: Buffer is not defined at encode (base64url.js:5) at Observable._zoneSubscribe (file-upload-service.ts:160) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe [as __zone_symbol__subscribe] (Observable.js:161) at Observable.value [as subscribe] (zone-patch-rxjs.js:95) at CatchOperator.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchOperator.call (catchError.js:17) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe [as __zone_symbol__subscribe] (Observable.js:158) at Observable.value [as subscribe] (zone-patch-rxjs.js:95) at subscribeTo.js:21 at subscribeToResult (subscribeToResult.js:6) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub (mergeMap.js:127)

I'm using base64url 3.0.0 with typescript. I also needed to manually add the following to your package.json to get it to work with noImpliciteany set to true.

"typings": "./dist/base64url.d.ts"

this issue has already been reported (https://github.com/brianloveswords/base64url/issues/29)

regards Ramila

ramila avatar Jun 11 '18 12:06 ramila

having this issue too

alexeichhorn avatar Sep 07 '18 23:09 alexeichhorn

This should be fixed in 3.0.1

https://github.com/brianloveswords/base64url/pull/32

MylesBorins avatar Nov 26 '18 00:11 MylesBorins

Doesnt work with Angular 7 still getting buffer is not defined, can someone else confirm?

Gabb1995 avatar Apr 09 '19 13:04 Gabb1995

Same thing here.

ghost avatar May 15 '19 22:05 ghost

So I'm guessing people are getting this error when using it in the browser. Reopening

MylesBorins avatar May 16 '19 05:05 MylesBorins

Yes for me, I wanted to use it in a angular project.

ghost avatar May 16 '19 11:05 ghost

Maybe installing this lib could be enough? I’ill give it a try https://www.npmjs.com/package/buffer

ghost avatar May 16 '19 11:05 ghost

For now , I have added this in my polyfill.js to fix this error.

global.Buffer = global.Buffer || require('buffer').Buffer;

and also installed package buffer from npm

npm install buffer --save-dev

vetrip avatar Aug 05 '19 18:08 vetrip

Hi, any update for this one ?

HDaghash avatar Feb 11 '20 11:02 HDaghash

Because this ticket exists nearly two years now... Any update on this?

manuel3108 avatar May 15 '20 13:05 manuel3108

I will remove myself from the notifications. For my project, I used js-base64 and it was good enough for my need.

ghost avatar May 15 '20 14:05 ghost

I'm getting this as well. Using 3.0.1. Trying to use in browser.

cullylarson avatar Apr 22 '21 03:04 cullylarson

Still an issue on latest version. I used it in angular 7.2.4. Not for all data. Only some.

jbalasingham avatar Apr 06 '23 02:04 jbalasingham

Any update on this issue guy's!.......am using "base64url": "^3.0.1", & "typescript": "^4.9.5",

edit:- this https://stackoverflow.com/questions/44458874/how-to-base64-encode-inputs-in-react helped some ppl but in my case am still getting "Buffer is not defined"

tusharp1206 avatar Dec 12 '23 05:12 tusharp1206