我正在尝试在Heroku上部署mt app,但我总是得到同样的错误:
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
Run Code Online (Sandbox Code Playgroud)
当我在类似的请求中读到时,我已经添加了一个包含以下代码的Procfile:web: node index.js但我仍然遇到同样的问题.
任何人都知道问题出在哪里?任何指导将不胜感激.先感谢您!
index.js文件在根目录中吗? web: node ./index.js
Run Code Online (Sandbox Code Playgroud)
app/src/index.js web: node ./src/index.js
Run Code Online (Sandbox Code Playgroud)
index.js有大写的“ I”吗?它必须是index.js,不是Index.js如果确实在项目的根目录中有index.js文件,但是heroku的错误表明找不到该模块。然后,您遇到的问题可能是由于GIT引起的。
我们如何确定是这种情况? 好吧,您的git repo可能没有在索引中添加index.js文件,也没有将其推送到heroku。您可以使用以下命令查看git在本地存储库中正在监视的文件来验证这一点:
git ls-files
Run Code Online (Sandbox Code Playgroud)
您的index.js文件应列出。如果不是,那么您的文件将被忽略。
解决方案:强制添加文件。
git add --force ./index.js
Run Code Online (Sandbox Code Playgroud)
现在,您可以提交并推送到heroku,您应该已启动并正在运行。
将索引文件放在dist目录或src(app / dist / index.js或app / src / index.js)中时,也可能是这种情况。
| 归档时间: |
|
| 查看次数: |
6313 次 |
| 最近记录: |