我正在尝试在 Heroku 上部署 mt 应用程序,但总是遇到相同的错误:
2016-08-18T10:16:10.988982+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-08-18T10:16:13.180369+00:00 app[web.1]: module.js:341
2016-08-18T10:16:13.180389+00:00 app[web.1]: throw err;
2016-08-18T10:16:13.180390+00:00 app[web.1]: ^
2016-08-18T10:16:13.180391+00:00 app[web.1]:
2016-08-18T10:16:13.180392+00:00 app[web.1]: Error: Cannot find module '/app/index.js'
2016-08-18T10:16:13.180393+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:339:15)
2016-08-18T10:16:13.180394+00:00 app[web.1]: at Function.Module._load (module.js:290:25)
2016-08-18T10:16:13.180394+00:00 app[web.1]: at Function.Module.runMain (module.js:447:10)
2016-08-18T10:16:13.180399+00:00 app[web.1]: at node.js:405:3
2016-08-18T10:16:13.271966+00:00 heroku[web.1]: Process exited with status 1
2016-08-18T10:16:13.273383+00:00 heroku[web.1]: State changed from starting to crashed
当我在类似的请求中读到时,我已经添加了一个包含以下代码的 Procfile:web: node index.js
,但我仍然有同样的问题。
有人知道问题出在哪里吗?任何指导将不胜感激。
先感谢您!
- Is your
index.js
文件在你的根目录下吗?
web: node ./index.js
- 你的文件可能像这样嵌套
app/src/index.js
web: node ./src/index.js
- 请问您
index.js
有一个大写的“I”吗?它一定要是index.js
并不是Index.js
If you do有你的index.js文件位于项目的根目录下,但是heroku's错误表明找不到该模块。那么,您遇到的问题可能是由于GIT.
我们如何确定情况确实如此?好吧,你的 git repo 可能没有添加你的index.js文件提交也不将其推送到 heroku。您可以通过查看以下文件来验证这一点git正在使用以下命令在本地存储库中观看:
git ls-files
Your index.js应列出文件。如果没有,那么您的文件将被忽略。
Solution:强制添加您的文件。
git add --force ./index.js
现在您可以提交并推送到heroku,并且您应该可以启动并运行。
当您的索引文件位于dist目录或src(app/dist/index.js 或 app/src/index.js)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)