node.jssocket.iorabbitmqnode-amqp

I am getting an error when i run my node.js app ( also using rabbit )


Error: Cannot find module 'amqplib/callback_api'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (C:\Users\hello\Downloads\Private-Chat-App-Socket.io- 
master\Private-Chat-App-Socket.io-master\app.js:3:9)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)

I have tried to solve the error by installing amqp using npm but it does not work and i have also searched for solutions on the internet but no luck.

Pic of the error


Solution

  • I just noticed you're declaring amqp twice. In line 3 and 6:

    var amqp = require('amqplip/callback_api'),
    

    So I will suggest you check your code and choose the one you'll wanna use.

    That aside, I think what you're trying to use is amqplib and not amqp

    To resolve your problem, I will suggest you delete the node_modules dir completely, then run npm install, after which you run these:

    npm install --save amqplib
    

    This should solve your problem.