简体   繁体   English

运行node.js应用程序时出现错误(也使用Rabbit)

[英]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来解决错误,但是它不起作用,并且我也在互联网上搜索了解决方案,但是没有运气。

Pic of the error 错误图片

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.

相关问题 尝试运行Node App时出现错误 - i am getting error when try to run my Node App 使用 express node.js 更新数据时出现错误 - i am getting an error while i am updating my data using express node.js 当我尝试在“node.js”中运行这行代码时,我收到以下错误 - When I try to run this line of code in “node.js”, I am getting the following error 我的服务器已启动,但是当我尝试连接它时,出现错误[Node.js] - My Server is up but when I try to connect to it I am getting an error [Node.js] 在 node.js 应用程序中创建一组类型的 redis 数据库时出现类型错误 - I am getting a Type Error when creating a set type of redis database in node.js app 当我运行我的 node.js 代码时,我没有得到我想要的输出这里有什么错误? - i am not getting my desired output when i run my node.js code what is the mistake here? 将我的项目上传到 Heroku 时出现此错误。 我正在使用 MapBox 和 node.js - I am getting this error while uploading my project to Heroku. I am using MapBox and node.js 我正在尝试将node js应用程序部署到heroku,但是在推送到master时仍然出现错误 - I am trying to deploy my node js app to heroku but I keep getting an error when pushing to master 为什么我在node.js应用程序中获得404状态? - Why am I getting a 404 status in my node.js app? 为什么我从node.js收到此错误? - Why am I getting this error from node.js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM