在Heroku上部署Node.js应用程序

我是初学者。 我尝试在Heroku上部署一个“应用程序”,但在https://peaceful-coast-7293.herokuapp.com/时无法使用。 它与英文heroku local正常工作。 真的不知道还有什么要检查的。

这是我在我的日志中得到的:

 2015-12-28T10:56:44.862230+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=peaceful-coast-7293.herokuapp.com request_id=c0994f20-ef28-4cad-95ba-f861a89d698d fwd="93.33.20.213" dyno= connect= service= status=503 bytes= 2015-12-28T10:56:45.457317+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=peaceful-coast-7293.herokuapp.com request_id=a3286f8e-7051-419d-9e3d-ccb2090659c0 fwd="93.33.20.213" dyno= connect= service= status=503 bytes= 

我也得到那些npm:

 2015-12-28T11:21:07.264470+00:00 heroku[web.1]: State changed from crashed to starting 2015-12-28T11:21:08.151361+00:00 heroku[web.1]: Starting process with command `npm start` 2015-12-28T11:21:10.533548+00:00 app[web.1]: npm ERR! Linux 3.13.0-71-generic 2015-12-28T11:21:10.534886+00:00 app[web.1]: npm ERR! node v0.12.7 2015-12-28T11:21:10.534398+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 2015-12-28T11:21:10.535773+00:00 app[web.1]: npm ERR! npm v2.11.3 2015-12-28T11:21:10.536011+00:00 app[web.1]: 2015-12-28T11:21:10.536325+00:00 app[web.1]: npm ERR! missing script: start 2015-12-28T11:21:10.536603+00:00 app[web.1]: npm ERR! 2015-12-28T11:21:10.536829+00:00 app[web.1]: npm ERR! If you need help, you may report this error at: 2015-12-28T11:21:10.537055+00:00 app[web.1]: npm ERR! <https://github.com/npm/npm/issues> 2015-12-28T11:21:10.544211+00:00 app[web.1]: 2015-12-28T11:21:10.544631+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 2015-12-28T11:21:10.544950+00:00 app[web.1]: npm ERR! /app/npm-debug.log 2015-12-28T11:21:11.360279+00:00 heroku[web.1]: State changed from starting to crashed 2015-12-28T11:21:11.348180+00:00 heroku[web.1]: Process exited with status 1 2015-12-28T11:35:00.705391+00:00 heroku[api]: Starting process with command `node console` by alessio.breviglieri@gmail.com 2015-12-28T11:35:02.612018+00:00 heroku[run.1521]: Awaiting client 2015-12-28T11:35:02.882034+00:00 heroku[run.1521]: State changed from starting to up 2015-12-28T11:35:32.616428+00:00 heroku[run.1521]: Error R13 (Attach error) -> Failed to attach to process 2015-12-28T11:35:33.493974+00:00 heroku[run.1521]: Process exited with status 128 2015-12-28T11:35:33.493559+00:00 heroku[run.1521]: State changed from up to complete 

我的app.js文件:

 var router = require('./router.js'); var port = process.env.PORT || 3000; //Create a web server var http = require('http'); http.createServer(function (request, response) { router.home(request, response); }).listen(port); console.log('Server running'); 

Procfile

 web: node app.js 

package.jsom

 { "name": "lorem_ipsum", "version": "1.0.0", "description": "Lorem Ipsum Generator", "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Alessio", "license": "MIT", "keywords": [ "lorem", "ipsum" ], "engines": { "node": "0.12.7" } } 

你需要添加

 "start": "node app.js" 

到你的package.json"scripts"部分。