node.js - Heroku 部署错误 : Cannot find module './errors/cast'

标签 node.js git angularjs heroku yeoman

我使用 yeoman Angular-fullstack 生成器构建了我的应用程序,然后根据自己的目的进行了修改。我使用 yo angular-fullstack:deploy heroku 构建了 dist 文件夹以部署到 heroku。它为我创建了一个新的 heroku 应用程序,当我 cd 进入 dist 文件夹并 git push heroku master 时,一切都很好。

我希望能够将现有的 heroku 应用程序添加到此 dist 文件夹的部署过程中,因此我遵循了这篇文章 How to link a folder with an existing Heroku app 。然后,我可以使用与 heroku 不同的远程名称部署到我自己的应用程序。

当它开始在heroku上运行时,我不断收到相同的错误。我不明白为什么完全相同的代码在为我创建的应用程序上运行良好,但在我现有的应用程序上运行不佳。这几乎就像我需要清除node_modules并再次推送?

    2014-02-21T04:43:51.989439+00:00 app[web.1]: module.js:340
    2014-02-21T04:43:51.996351+00:00 app[web.1]: Error: Cannot find module './errors/cast'
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
    2014-02-21T04:43:51.991555+00:00 app[web.1]:     throw err;
    2014-02-21T04:43:51.991785+00:00 app[web.1]:           ^
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at require (module.js:380:17)
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Module.require (module.js:36         4:17)
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Module._compile (module.js:456:26)
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/mongoose/lib/error.js:32:27)
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Module.load (module.js:356:32)
    2014-02-21T04:43:51.996351+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
    2014-02-21T04:43:51.996560+00:00 app[web.1]:     at Module.require (module.js:364:17)
    2014-02-21T04:43:53.457214+00:00 heroku[web.1]: State changed from starting to crashed

这是 dist 文件夹中的 packages.json

   {
       "name": "myapp",
       "version": "1.0.0",
       "dependencies": {
         "express": "~3.4.3",
         "lodash": "~2.4.1",
         "mongoose": "~3.5.5",
         "mongoose-unique-validator": "~0.3.0",
         "connect-mongo": "~0.4.0",
         "passport": "latest",
         "passport-local": "latest",
         "passport-facebook": "latest",
         "passport-twitter": "latest",
         "passport-google": "latest",
         "ejs": "~0.8.4"
       },
       "engines": {
         "node": ">=0.10.0"
        },
        "scripts": {
          "test": "grunt test"
        }
      }

最佳答案

问题几乎可以肯定是您没有 checkin 您需要的所有文件。如果您在 git 存储库中看不到问题,请尝试运行 heroku run bash 并使用 cdlsmore 查看部署到 Heroku 的内容并查看缺少的内容。

您的问题可能是您有 require('./errors/cast') 但尚未 checkin 强制转换文件。

更新:

另一种可能是您在不区分大小写的 OS X 上 checkin 了 ./errors/Cast,但在区分大小写的 Linux 上找不到该文件。

关于node.js - Heroku 部署错误 : Cannot find module './errors/cast' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21925940/

相关文章:

javascript - Jade 条件(if/else)将类添加到 div 内联

尝试检索日志消息的 Git 错误

angularjs - Mongoose 和 Node.js Multi-Tenancy 架构

javascript - printThis.js 有时不打印内容

javascript - Node.js Express 中的 HTTP GET 请求

node.js - 您如何在 Node.js 中遵循 HTTP 重定向?

git - Xcode 4 混帐 —"This file does not exist at the requested revision"

javascript - 如何在 Leaflet map 上打印/显示/绘制 MultiPolygon GeoJSON

javascript - 如何在 npm 中删除 dedupe 选项

git - 为什么不建议将 git 存储库放在 Dropbox 文件夹中?