I need some help cause I don't have any idea what to do. I have to use 'amqplib' in my Angular project. Firstly I have tried to use 'amqp-ts', but as soon as I've opened a browser I had an error:
After several tries, I have switched to 'amqplib'. However when I'm trying call library's functions I get an error:
The error occurs in line:
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer
} else {
// Copy properties from require('buffer')
copyProps(buffer, exports)
exports.Buffer = SafeBuffer
}
so again, Buffer is not defined.
I've tried several solutions mentioned here: Angular 6 Uncaught ReferenceError: Buffer is not defined and I have ended up with: -installed 'buffer' package
-in polyfills.ts
declare var require: any;
declare var global: any;
(window as any).global = window;
// @ts-ignore
window.Buffer = window.Buffer || require('buffer').Buffer;
(window as any).process = {
version: ''
};
-in index.html
<script>
var global = global || window;
</script>
Nevertheless, none of them helped and still I have these errors :/