【问题标题】:Heroku nodejs application error can't find app/index.jsHeroku nodejs应用程序错误找不到app/index.js
【发布时间】:2018-07-07 15:41:36
【问题描述】:

我不断收到以下错误日志

Heroku 错误:找不到模块“/app/index.js”

在本地服务器上工作正常吗?

State changed from starting to crashed
rwa@1.0.0 start /app
node index.js

module.js:538
throw err;

Error: Cannot find module '/app/index.js'
   at Function.Module._resolveFilename (module.js:536:15)

我似乎无法让它在 Heroku 部署中运行,有什么想法吗?我已经添加了一个正确的 Procfile (web: node index.js),甚至在package.json 文件中正确添加了npm start

【问题讨论】:

  • 你是否在 package.json 中添加了启动脚本
  • @deepakthomas 是的,我添加了“start”:“node index.js”
  • @deepakthomas 哦,等等,它现在以某种方式工作..
  • @deepakthomas 你做了什么?
  • Heroku 在 package.json 中查找启动脚本,如果它没有找到它运行导致错误的默认启动脚本

标签: node.js heroku


【解决方案1】:

通过在 package.json 中添加启动脚本将解决您的问题,因为 Heroku 会在 package.json 中查找启动脚本,如果找不到它会运行导致错误的默认启动脚本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-25
    • 2021-08-17
    • 2021-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多