I am migrating an Angular 5 app to version 7 and have hit an issue with some existing code that attempts to use a Buffer global.
The code in question comes from the btoa library which makes use of the global.
In my migrated Angular 7 app, I am getting ReferenceError: Buffer is not defined and is being thrown when attempting to call the btoa function exported from this library.
This however works all fine in my Angular 5 app.
What could be going on here? I am assuming it has to do with a change in the angular CLI and maybe the way webpack is bundling somehow?
I saw a similar question here talking about related issues, and one suggestion was to install the buffer package, which I tried, but it made no difference for my situation.
Thanks
"node"to yourtsconfig.json->compilerOptions->typesarray?Bufferglobal which is only available insidenode. Not in the browser. For proper compilation, you need to have the node js typings, andnodeinside your types array. If you do not run your application inside nodejs, you don't need the btoa package