2016-05-02 28 views
0

私は基本的なNode.js HTTPリクエスト&レスポンスアプリケーションをステップバイステップのチュートリアルの後に書いています。Heroku + Node.js(express) - アプリケーションエラー

私がURLにアクセスすると、Herokuにデプロイされた後、「アプリケーションエラー」が表示されます。

すでに同じことが起こっています。私はしばらく待って、Herokuアプリを削除し、Herokuアプリを押し戻して、もう一度うまくいきました。

その後、再び停止しました。

私がGETとPOSTクエリ(Postman経由)を試みると、 "503 Service Unavailable"エラーが発生します。

ノードの問題を開くように指示するHerokuログを添付しますが、ローカル(localhost:3000)は正常に動作しています。 エラーはH10 "App Crashed" 誰かが問題の原因を知っている可能性があります。

私はNode.jsのコードを添付:助けるため

var express = require('express'); 
var bodyParser = require('body-Parser'); 
var _ = require('underscore'); 

var app = express(); 
var PORT = process.env.PORT || 3000; 
var todos = []; 
var todoNextId = 1; 
app.use(bodyParser.json()); 

//GET /[root] 
app.get('/', function (req, res) { 
    res.send('Todo API Root'); 
}); 

//GET /todos 
app.get('/todos', function (req, res) { 
    res.json(todos); 
}); 

//GET /todos/:id 
app.get('/todos/:id', function (req, res) { 
    var todoId = parseInt(req.params.id); 
    var matchedToDo = _.findWhere(todos, {id: todoId}); 

    if (matchedToDo) { 
     res.json(matchedToDo); 
    } else { 
     res.status(404).send(); 
    } 
}); 

//POST /todos 
app.post('/todos', function (req, res) { 
    var body = _.pick(req.body, 'description', 'completed'); 

    if (!_.isBoolean(body.completed) || !_.isString(body.description) || body.description.trim().length === 0) { 
     return res.status(400).send(); 
    } 

    body.description = body.description.trim(); 

    body.id = todoNextId++; 

    todos.push(body); 

    res.json(body); 
}); 

app.listen(PORT, function(){ 
console.log('Express listening on port ' + PORT); 
}); 

感謝を。

2016-05-02T17:08:52.094535+00:00 heroku[api]: Enable Logplex by [email protected] 2016-05-02T17:08:52.094582+00:00 heroku[api]: Release v2 created by [email protected] 
2016-05-02T17:10:19.718255+00:00 heroku[api]: Scale to web=1 by [email protected] 
2016-05-02T17:10:19.719361+00:00 heroku[api]: Release v3 created by [email protected] 
2016-05-02T17:10:19.719361+00:00 heroku[api]: Deploy 7c303de by [email protected] 
2016-05-02T17:10:20.663812+00:00 heroku[slug-compiler]: Slug compilation started 
2016-05-02T17:10:20.663829+00:00 heroku[slug-compiler]: Slug compilation finished 
2016-05-02T17:10:22.387983+00:00 heroku[web.1]: Starting process with command `npm start` 
2016-05-02T17:10:24.378611+00:00 app[web.1]: > [email protected] start /app 
2016-05-02T17:10:24.378615+00:00 app[web.1]: > node server.js 
2016-05-02T17:10:24.378616+00:00 app[web.1]: 
2016-05-02T17:10:24.378601+00:00 app[web.1]: 
2016-05-02T17:10:24.539535+00:00 app[web.1]: ^
2016-05-02T17:10:24.539505+00:00 app[web.1]: module.js:327 
2016-05-02T17:10:24.539535+00:00 app[web.1]: 
2016-05-02T17:10:24.539533+00:00 app[web.1]:  throw err; 
2016-05-02T17:10:24.539538+00:00 app[web.1]:  at Module.require (module.js:353:17) 
2016-05-02T17:10:24.539539+00:00 app[web.1]:  at require (internal/module.js:12:17) 
2016-05-02T17:10:24.539537+00:00 app[web.1]:  at Function.Module._resolveFilename (module.js:325:15) 
2016-05-02T17:10:24.539538+00:00 app[web.1]:  at Function.Module._load (module.js:276:25) 
2016-05-02T17:10:24.539539+00:00 app[web.1]:  at Object.<anonymous> (/app/server.js:2:18) 
2016-05-02T17:10:24.539541+00:00 app[web.1]:  at Object.Module._extensions..js (module.js:416:10) 
2016-05-02T17:10:24.539543+00:00 app[web.1]:  at Function.Module.runMain (module.js:441:10) 
2016-05-02T17:10:24.539541+00:00 app[web.1]:  at Module.load (module.js:343:32) 
2016-05-02T17:10:24.539540+00:00 app[web.1]:  at Module._compile (module.js:409:26) 
2016-05-02T17:10:24.539536+00:00 app[web.1]: Error: Cannot find module 'body-Parser' 
2016-05-02T17:10:24.552923+00:00 app[web.1]: npm ERR! Linux 3.13.0-79-generic 
2016-05-02T17:10:24.553580+00:00 app[web.1]: npm ERR! node v4.4.3 
2016-05-02T17:10:24.546698+00:00 app[web.1]: 
2016-05-02T17:10:24.554229+00:00 app[web.1]: npm ERR! npm v2.15.1 
2016-05-02T17:10:24.555005+00:00 app[web.1]: npm ERR! Exit status 1 
2016-05-02T17:10:24.539542+00:00 app[web.1]:  at Function.Module._load (module.js:300:12) 
2016-05-02T17:10:24.554626+00:00 app[web.1]: npm ERR! code ELIFECYCLE 
2016-05-02T17:10:24.555172+00:00 app[web.1]: npm ERR! 
2016-05-02T17:10:24.555617+00:00 app[web.1]: npm ERR! not with npm itself. 
2016-05-02T17:10:24.555698+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 
2016-05-02T17:10:24.555885+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 
2016-05-02T17:10:24.555495+00:00 app[web.1]: npm ERR! This is most likely a problem with the todo-api package, 
2016-05-02T17:10:24.554849+00:00 app[web.1]: npm ERR! [email protected] start: `node server.js` 
2016-05-02T17:10:24.553350+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 
2016-05-02T17:10:24.556081+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 
2016-05-02T17:10:24.555346+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'node server.js'. 
2016-05-02T17:10:24.556309+00:00 app[web.1]: npm ERR!  npm owner ls todo-api 
2016-05-02T17:10:24.555786+00:00 app[web.1]: npm ERR!  node server.js 
2016-05-02T17:10:24.555982+00:00 app[web.1]: npm ERR!  npm bugs todo-api 
2016-05-02T17:10:24.556157+00:00 app[web.1]: npm ERR! 
2016-05-02T17:10:24.559818+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 
2016-05-02T17:10:24.559924+00:00 app[web.1]: npm ERR!  /app/npm-debug.log 
2016-05-02T17:10:24.556417+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 
2016-05-02T17:10:24.559659+00:00 app[web.1]: 
2016-05-02T17:10:25.340763+00:00 heroku[web.1]: State changed from starting to crashed 
2016-05-02T17:10:25.341871+00:00 heroku[web.1]: State changed from crashed to starting 
2016-05-02T17:10:25.335969+00:00 heroku[web.1]: Process exited with status 1 
2016-05-02T17:10:26.442330+00:00 heroku[web.1]: Starting process with command `npm start` 
2016-05-02T17:10:29.267867+00:00 app[web.1]: 
2016-05-02T17:10:29.267893+00:00 app[web.1]: > [email protected] start /app 
2016-05-02T17:10:29.267895+00:00 app[web.1]: 
2016-05-02T17:10:29.267894+00:00 app[web.1]: > node server.js 
2016-05-02T17:10:29.703937+00:00 app[web.1]: module.js:327 
2016-05-02T17:10:29.703975+00:00 app[web.1]:  throw err; 
2016-05-02T17:10:29.703978+00:00 app[web.1]: ^
2016-05-02T17:10:29.703978+00:00 app[web.1]: 
2016-05-02T17:10:29.703985+00:00 app[web.1]:  at Function.Module._resolveFilename (module.js:325:15) 
2016-05-02T17:10:29.703988+00:00 app[web.1]:  at Module._compile (module.js:409:26) 
2016-05-02T17:10:29.703989+00:00 app[web.1]:  at Module.load (module.js:343:32) 
2016-05-02T17:10:29.703990+00:00 app[web.1]:  at Function.Module._load (module.js:300:12) 
2016-05-02T17:10:29.721879+00:00 app[web.1]: 
2016-05-02T17:10:29.733721+00:00 app[web.1]: npm ERR! Linux 3.13.0-79-generic 
2016-05-02T17:10:29.703990+00:00 app[web.1]:  at Function.Module.runMain (module.js:441:10) 
2016-05-02T17:10:29.734824+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 
2016-05-02T17:10:29.703987+00:00 app[web.1]:  at require (internal/module.js:12:17) 
2016-05-02T17:10:29.703984+00:00 app[web.1]: Error: Cannot find module 'body-Parser' 
2016-05-02T17:10:29.703988+00:00 app[web.1]:  at Object.<anonymous> (/app/server.js:2:18) 
2016-05-02T17:10:29.703986+00:00 app[web.1]:  at Module.require (module.js:353:17) 
2016-05-02T17:10:29.703989+00:00 app[web.1]:  at Object.Module._extensions..js (module.js:416:10) 
2016-05-02T17:10:29.703986+00:00 app[web.1]:  at Function.Module._load (module.js:276:25) 
2016-05-02T17:10:29.737258+00:00 app[web.1]: npm ERR! npm v2.15.1 
2016-05-02T17:10:29.737687+00:00 app[web.1]: npm ERR! code ELIFECYCLE 
2016-05-02T17:10:29.735275+00:00 app[web.1]: npm ERR! node v4.4.3 
2016-05-02T17:10:29.738035+00:00 app[web.1]: npm ERR! [email protected] start: `node server.js` 
2016-05-02T17:10:29.738349+00:00 app[web.1]: npm ERR! Exit status 1 
2016-05-02T17:10:29.738718+00:00 app[web.1]: npm ERR! 
2016-05-02T17:10:29.739200+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'node server.js'. 
2016-05-02T17:10:29.740147+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 
2016-05-02T17:10:29.739540+00:00 app[web.1]: npm ERR! This is most likely a problem with the todo-api package, 
2016-05-02T17:10:29.739862+00:00 app[web.1]: npm ERR! not with npm itself. 
2016-05-02T17:10:29.740460+00:00 app[web.1]: npm ERR!  node server.js 
2016-05-02T17:10:29.740772+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 
2016-05-02T17:10:29.741082+00:00 app[web.1]: npm ERR!  npm bugs todo-api 
2016-05-02T17:10:29.741644+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 
2016-05-02T17:10:29.741966+00:00 app[web.1]: npm ERR! 
2016-05-02T17:10:29.742244+00:00 app[web.1]: npm ERR!  npm owner ls todo-api 
2016-05-02T17:10:29.742560+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 
2016-05-02T17:10:29.747872+00:00 app[web.1]: 
2016-05-02T17:10:29.748529+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 
2016-05-02T17:10:29.748823+00:00 app[web.1]: npm ERR!  /app/npm-debug.log 
2016-05-02T17:10:30.824809+00:00 heroku[web.1]: Process exited with status 1 
2016-05-02T17:10:30.842383+00:00 heroku[web.1]: State changed from starting to crashed 
2016-05-02T17:10:34.224806+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=matteo-todo-api.herokuapp.com request_id=f4914bf6-ae6a-4390-a598-ba1e2aa6d598 fwd="2.233.72.96" dyno= connect= service= status=503 bytes= 
2016-05-02T17:10:35.375423+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=matteo-todo-api.herokuapp.com request_id=69fe5fe5-9945-4a77-8ca9-564389b58aa9 fwd="2.233.72.96" dyno= connect= service= status=503 bytes= 

答えて

0

あなたは間違った依存関係があります。 body-Parserbody-parserである必要があります。小さい「p」は資本「P」ではない。

+0

それでした。 Deendayalありがとうございました。大いに感謝する! –

関連する問題