This error is caused by a missing Buffer object in the Vue project. The amqplib library needs to use Buffer objects to process binary data at runtime, and in the Vue project, the Buffer objects may not be introduced correctly.
There are two solutions:
- Introduce the Buffer object in the main.js file, such as:
global.Buffer = global.Buffer || require('buffer').Buffer
2. Add the following configuration to the webpack.config.js file:
node: {
Buffer: true
}
This way you can use amqplib in vue.