Node.js应用程序在本地工作,但Heroku说缺少模块 [英] Node.js app works locally but heroku says missing module
问题描述
我使用Node.JS和Socket.IO创建了一个简单的聊天应用程序,本地一切正常,但是当我将它推送到heroku时,它给我一个应用程序错误,当我检查日志时,这是错误: p>
I made a simple chat application using Node.JS and Socket.IO, everything works fine locally, but when I push it to heroku it gives me an application error, when I check the logs, this is the error:
Error: Cannot find module 'indexof'
at Function.Module._resolveFilename <module.js:338:15>
at Function.Module._load <module.js:280:25>
at Module.require <module.js:364:17>
at require <module.js:380:17>
at Object.<anonymous> </app/node_modules/socket.io/node_modules/socket.io-parser/node_modules/emitter/index.js:6:13>
at Module._compile <module.js:456:26>
at Object.Module._extensions..js <module.js:474:10>
at Module.load <module.js:356:32>
at Functin.Module._load <module.js:312:12>
at Module.require <module.js:364:17>
所以我发现indexof是Socket.IO使用的模块,它位于我的node_modules文件夹,但由于某种原因,它不会被推送到heroku或它只是不被识别。我重新安装了我的模块5-6次,并重新创建应用程序,但它仍然给我同样的错误。我的package.json文件有3个依赖项:Express,Socket.IO和Jade
So I figured out that indexof is a module that Socket.IO uses, and it is in my node_modules folder, but for some reason either it's not being pushed to heroku or it's just not being recognized. I reinstalled my modules 5-6 times and recreated the app but it's still giving me the same error. My package.json file has 3 dependencies: Express, Socket.IO and Jade
推荐答案
好了2个小时后我发现问题out,包含indexof模块的名为emitter的多个文件夹也有一个让git忽略该模块的gitignore文件,不知道为什么它甚至存在,但删除它们解决了问题。
Alright so after 2 hours I figured the problem out, multiple folders named "emitter" that contained the indexof module also had a gitignore file that made git ignore the module, no idea why that was even there, but deleting them fixed the problem
这篇关于Node.js应用程序在本地工作,但Heroku说缺少模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!