未捕获的 TypeError: __webpack_require__(...).connect 不是 Object.connect (

yos*_*lah 5 rpc rabbitmq reactjs

我收到此错误

图像

当我尝试在 React 项目上测试代码时:

var amqp = require('amqplib/callback_api');


export function start2 (conn) {

console.log("hello")

amqp.connect('amqp://localhost:8000', function (err, conn) {

    conn.createChannel(function(err, ch) {
        var q = 'frontend';
        var msg = 'Hello!';

        ch.assertQueue(q, {durable: false});
        // Note: on Node 6 Buffer.from(msg) should be used
        ch.sendToQueue(q, new Buffer(msg));
        console.log(" [x] Sent %s", msg);
    });
    setTimeout(function() { conn.close(); process.exit(0) }, 500);



});

}
Run Code Online (Sandbox Code Playgroud)

任何帮助,谢谢。