[英]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. 我试图通过使用npm安装amqp来解决错误,但是它不起作用,并且我也在互联网上搜索了解决方案,但是没有运气。
I just noticed you're declaring amqp
twice. 我只是注意到您两次声明了amqp
。 In line 3 and 6: 在第3行和第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 除此之外,我认为您要使用的是amqplib而不是amqp
To resolve your problem, I will suggest you delete the node_modules
dir completely, then run npm install
, after which you run these: 要解决您的问题,我建议您完全删除node_modules
目录,然后运行npm install
,然后运行以下命令:
npm install --save amqplib
This should solve your problem. 这应该可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.