【问题标题】:Heroku Deploy Error: Cannot find module './errors/cast'Heroku 部署错误:找不到模块'./errors/cast'
【发布时间】:2014-03-22 11:11:42
【问题描述】:

我使用 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"
        }
      }

【问题讨论】:

    标签: node.js git angularjs heroku yeoman


    【解决方案1】:

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

    您的问题很可能是您有require('./errors/cast'),但尚未签入演员表文件。

    更新:

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

    【讨论】:

    • 大小写不敏感/敏感部分为我解决了同样的问题
    猜你喜欢
    • 2021-03-17
    • 2019-01-27
    • 2016-12-25
    • 2021-08-17
    • 1970-01-01
    • 1970-01-01
    • 2018-11-07
    • 2017-06-07
    • 1970-01-01
    相关资源
    最近更新 更多