Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Node.js应用程序部署到Heroku时出现应用程序错误_Node.js_Heroku_Deployment_Web Deployment - Fatal编程技术网

将Node.js应用程序部署到Heroku时出现应用程序错误

将Node.js应用程序部署到Heroku时出现应用程序错误,node.js,heroku,deployment,web-deployment,Node.js,Heroku,Deployment,Web Deployment,我不熟悉将Github项目部署到Heroku。到目前为止,我已经成功地将我的应用程序连接到Heroku并已部署。该项目在我的本地机器上运行良好。然而,当我尝试启动我的应用程序的heroku网站时,它给了我以下错误: “应用程序中出现错误,无法访问您的页面 已送达。请稍后再试 如果您是应用程序所有者,请查看日志以了解详细信息。” 这是我的heroku日志,我很难理解 2015-11-10T04:33:10.538175+00:00 heroku[router]: at=error code=H10

我不熟悉将Github项目部署到Heroku。到目前为止,我已经成功地将我的应用程序连接到Heroku并已部署。该项目在我的本地机器上运行良好。然而,当我尝试启动我的应用程序的heroku网站时,它给了我以下错误:

“应用程序中出现错误,无法访问您的页面 已送达。请稍后再试

如果您是应用程序所有者,请查看日志以了解详细信息。”

这是我的heroku日志,我很难理解

2015-11-10T04:33:10.538175+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=af3a9061-1b8f-47fe-9e2e-eafa624f2712 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:33:10.649481+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=e8fc1b43-f629-4e38-85c9-808d731e852e fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:33:11.334843+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=149ffc6c-8a57-475c-9f64-5224bcf72bfd fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:33:12.207897+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=4585d320-5d3b-43a0-ab85-a84f9734e373 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:35:18.757410+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=1d59ddd7-ff62-4b01-8b3a-df450fac5ba5 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:35:19.737947+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=2f8f9bc8-8299-4da9-bdad-eed9fa537573 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:35:19.503853+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=77870378-cde5-48e2-b4d2-e93526b1e10d fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:41:09.087924+00:00 heroku[api]: Deploy 5c325e8 by myemail@gmail.com
2015-11-10T04:41:09.087924+00:00 heroku[api]: Release v6 created by myemail@gmail.com
2015-11-10T04:41:09.271289+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-10T04:41:09.271300+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-10T04:41:11.469002+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:41:12.469938+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:41:14.322786+00:00 app[web.1]: module.js:339
2015-11-10T04:41:14.322794+00:00 app[web.1]:     throw err;
2015-11-10T04:41:14.322795+00:00 app[web.1]:     ^
2015-11-10T04:41:14.322796+00:00 app[web.1]:
2015-11-10T04:41:14.322797+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:41:14.322797+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:41:14.322798+00:00 app[web.1]:     at Function.Module._load (module.js:287:25)
2015-11-10T04:41:14.322799+00:00 app[web.1]:     at Module.require (module.js:366:17)
2015-11-10T04:41:14.322799+00:00 app[web.1]:     at require (module.js:385:17)
2015-11-10T04:41:14.322800+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:41:14.322800+00:00 app[web.1]:     at Module._compile (module.js:425:26)
2015-11-10T04:41:14.322801+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:41:14.322802+00:00 app[web.1]:     at Module.load (module.js:356:32)
2015-11-10T04:41:14.322802+00:00 app[web.1]:     at Function.Module._load (module.js:311:12)
2015-11-10T04:41:14.322803+00:00 app[web.1]:     at Function.Module.runMain (module.js:457:10)
2015-11-10T04:41:15.124877+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:41:15.116760+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:44:48.813133+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=81fddfea-92e6-4c64-91aa-ec5d076fb8e6 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:44:49.590449+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=efa1b5fc-5a1e-4b31-acef-5a1025e8c99d fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:44:49.955648+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=4af0cf53-ea53-4361-a5d2-6a3efc51a62f fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:51:46.883632+00:00 heroku[api]: Deploy b0f6afe by myemail@gmail.com
2015-11-10T04:51:46.883703+00:00 heroku[api]: Release v7 created by myemail@gmail.com
2015-11-10T04:51:46.979243+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:51:47.041376+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-10T04:51:47.041386+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-10T04:51:48.436794+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:51:50.436732+00:00 app[web.1]: module.js:339
2015-11-10T04:51:50.436759+00:00 app[web.1]:     at Function.Module._load (module.js:287:25)
2015-11-10T04:51:50.436761+00:00 app[web.1]:     at Module._compile (module.js:425:26)
2015-11-10T04:51:50.436754+00:00 app[web.1]:     throw err;
2015-11-10T04:51:50.436756+00:00 app[web.1]:
2015-11-10T04:51:50.436763+00:00 app[web.1]:     at Function.Module._load (module.js:311:12)
2015-11-10T04:51:50.436755+00:00 app[web.1]:     ^
2015-11-10T04:51:50.436759+00:00 app[web.1]:     at Module.require (module.js:366:17)
2015-11-10T04:51:50.436757+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:51:50.436758+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:51:50.436762+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:51:50.436764+00:00 app[web.1]:     at Function.Module.runMain (module.js:457:10)
2015-11-10T04:51:50.436760+00:00 app[web.1]:     at require (module.js:385:17)
2015-11-10T04:51:50.436760+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:51:50.436762+00:00 app[web.1]:     at Module.load (module.js:356:32)
2015-11-10T04:51:51.157210+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:51:52.735586+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:51:55.545983+00:00 app[web.1]: module.js:339
2015-11-10T04:51:55.545998+00:00 app[web.1]:     throw err;
2015-11-10T04:51:55.545999+00:00 app[web.1]:     ^
2015-11-10T04:51:55.545999+00:00 app[web.1]:
2015-11-10T04:51:55.546001+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:51:55.546002+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:51:55.546002+00:00 app[web.1]:     at Function.Module._load (module.js:287:25)
2015-11-10T04:51:55.546003+00:00 app[web.1]:     at Module.require (module.js:366:17)
2015-11-10T04:51:55.546003+00:00 app[web.1]:     at require (module.js:385:17)
2015-11-10T04:51:55.546004+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:51:55.546004+00:00 app[web.1]:     at Module._compile (module.js:425:26)
2015-11-10T04:51:55.546005+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:51:55.546006+00:00 app[web.1]:     at Module.load (module.js:356:32)
2015-11-10T04:51:55.546007+00:00 app[web.1]:     at Function.Module.runMain (module.js:457:10)
2015-11-10T04:51:55.546006+00:00 app[web.1]:     at Function.Module._load (module.js:311:12)
2015-11-10T04:51:51.172084+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:51:51.173050+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:51:56.492216+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:51:56.506380+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:53:27.766915+00:00 heroku[api]: Deploy 15c64ba by myemail@gmail.com
2015-11-10T04:53:27.766915+00:00 heroku[api]: Release v8 created by myemail@gmail.com
2015-11-10T04:53:27.910792+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-10T04:53:27.910801+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-10T04:53:27.921730+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-10T04:53:29.221014+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-11-10T04:53:31.264123+00:00 app[web.1]: module.js:339
2015-11-10T04:53:31.264132+00:00 app[web.1]:     throw err;
2015-11-10T04:53:31.264133+00:00 app[web.1]:     ^
2015-11-10T04:53:31.264134+00:00 app[web.1]:
2015-11-10T04:53:31.264135+00:00 app[web.1]: Error: Cannot find module 'express3-handlebars'
2015-11-10T04:53:31.264136+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:337:15)
2015-11-10T04:53:31.264136+00:00 app[web.1]:     at Function.Module._load (module.js:287:25)
2015-11-10T04:53:31.264137+00:00 app[web.1]:     at Module.require (module.js:366:17)
2015-11-10T04:53:31.264138+00:00 app[web.1]:     at require (module.js:385:17)
2015-11-10T04:53:31.264138+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:6:18)
2015-11-10T04:53:31.264139+00:00 app[web.1]:     at Module._compile (module.js:425:26)
2015-11-10T04:53:31.264140+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:432:10)
2015-11-10T04:53:31.264140+00:00 app[web.1]:     at Module.load (module.js:356:32)
2015-11-10T04:53:31.264141+00:00 app[web.1]:     at Function.Module._load (module.js:311:12)
2015-11-10T04:53:31.264141+00:00 app[web.1]:     at Function.Module.runMain (module.js:457:10)
2015-11-10T04:53:31.969583+00:00 heroku[web.1]: Process exited with status 1
2015-11-10T04:53:31.989169+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-10T04:54:44.812224+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=compasss.herokuapp.com request_id=a508a64d-8a85-4d09-a610-67ef57854186 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:54:45.733283+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=1a312b38-8793-41fa-9a77-2d2e7f0c63f2 fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
2015-11-10T04:54:45.461863+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=compasss.herokuapp.com request_id=47d48dc9-3e16-4b49-8b25-7b56a8b3ccad fwd="138.110.234.184" dyno= connect= service= status=503 bytes=
这是我的
包.json

{
  "name": "Compass",
  "version": "1.0.0",
  "description": "Independent Study Application",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js"
  },
  "author": "Thao Bach",
  "license": "ISC",
  "dependencies": {
    "express": "^4.13.3",
    "express-handlebars": "^2.0.1",
    "mongodb": "^2.0.46",
    "monk": "^1.0.1"
  },
  "devDependencies": {
    "archiver": "^0.15.1",
    "chai": "^3.3.0",
    "fs-extra": "^0.24.0",
    "mocha": "^2.3.3"
  }
}

很可能您没有在
package.json
中提到npm依赖项
express3把手
,或者在
package.json
文件中提到它作为开发依赖项

另外,在您的app.js中,您正在使用

var handlebars = require('express3-handlebars')
  .create({ defaultLayout:'main' });

您可能希望将require语句更改为指向
expresshandlebar
或将
express3 handlebar
作为依赖项包含在内

您可以显示您的包.json吗?为什么我在本地运行时它不抱怨?此外,如何包括express3把手?除了“ExpressHandlebar”之外,我是否应该添加它“^2.0.1”?请参阅本地计算机上根应用程序目录中的“npm list express3 handlebars”命令,作为您在app.js“var handlebar=require('express3-handlebar')上的语句正在通过您可能意外地在本地计算机上安装了全局或仅安装在您的应用程序文件夹中,而没有在软件包中将其标记为依赖项。jsonI将require('express3-handlebar')更改为require('express3-handlebar'),并且成功了!非常感谢。
var handlebars = require('express3-handlebars')
  .create({ defaultLayout:'main' });