Node.js应用程序在本地工作,但heroku说缺少模块

fic*_*ion 20 heroku node.js socket.io

我使用Node.JS和Socket.IO创建了一个简单的聊天应用程序,一切都在本地工作正常,但当我将它推送到heroku它给我一个应用程序错误,当我检查日志时,这是错误:

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>
Run Code Online (Sandbox Code Playgroud)

所以我发现indexof是Socket.IO使用的模块,它位于我的node_modules文件夹中,但由于某种原因它要么没有被推送到heroku,要么就是没有被识别.我重新安装我的模块5-6次并重新创建应用程序,但它仍然给我同样的错误.我的package.json文件有3个依赖项:Express,Socket.IO和Jade

fic*_*ion 33

好吧所以2小时后我想出了问题,多个文件夹名为"emitter",其中包含indexof模块也有一个gitignore文件,让git忽略了模块,不知道为什么那就是那里,但删除它们修复了问题

  • 我有完全相同的问题.然后我用`git add -A --force`解决了它. (17认同)