私は基本的にここに彼らの指示に従ってHerokuの上でアプリのNode.js一緒にサンプルを置くことを試みてきた(毎回クラッシュする):https://devcenter.heroku.com/articles/nodejsが正常にHerokuの上のNode.jsアプリケーションを実行できません
アプリforeman start
でローカルに細かい動作しますしかし、私はそれがクラッシュするアプリを展開するたびに。 私は間違って何をしていますか?
マイProcfile
が含まれています:
web: node web.js
私package.json
は含まれています
{
"name": "testapp",
"version": "0.0.1",
"engines": {
"node": "0.6.15"
, "npm": "1.1.9"
}
, "dependencies": {
"tower": "0.4.0-12"
}
}
私web.js
は含まれています
var express = require('express');
var app = express.createServer(express.logger());
app.get('/', function(request, response) {
response.send('Hello World!');
});
var port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("Listening on " + port);
});
アプリがデプロイされて起動しますが、毎回クラッシュします。私がアプリから見るログの出力は次の通りです:
2012-04-27T20:21:31+00:00 heroku[web.1]: State changed from created to starting
2012-04-27T20:21:37+00:00 heroku[web.1]: Starting process with command `node web.js`
2012-04-27T20:21:38+00:00 app[web.1]:
2012-04-27T20:21:38+00:00 app[web.1]: node.js:201
2012-04-27T20:21:38+00:00 app[web.1]: throw e; // process.nextTick error, or 'error' event on first tick
2012-04-27T20:21:38+00:00 app[web.1]: ^
2012-04-27T20:21:38+00:00 app[web.1]: Error: Cannot find module 'express'
2012-04-27T20:21:38+00:00 app[web.1]: at Function._resolveFilename (module.js:332:11)
2012-04-27T20:21:38+00:00 app[web.1]: at Function._load (module.js:279:25)
2012-04-27T20:21:38+00:00 app[web.1]: at Module.require (module.js:354:17)
2012-04-27T20:21:38+00:00 app[web.1]: at require (module.js:370:17)
2012-04-27T20:21:38+00:00 app[web.1]: at Object.<anonymous> (/app/web.js:1:77)
2012-04-27T20:21:38+00:00 app[web.1]: at Module._compile (module.js:441:26)
2012-04-27T20:21:38+00:00 app[web.1]: at Object..js (module.js:459:10)
2012-04-27T20:21:38+00:00 app[web.1]: at Module.load (module.js:348:31)
2012-04-27T20:21:38+00:00 app[web.1]: at Function._load (module.js:308:12)
2012-04-27T20:21:38+00:00 app[web.1]: at Array.0 (module.js:479:10)
2012-04-27T20:21:39+00:00 heroku[web.1]: Process exited with status 1
2012-04-27T20:21:40+00:00 heroku[web.1]: State changed from starting to crashed
2012-04-27T20:30:01+00:00 heroku[router]: Error H10 (App crashed) -> GET testapp.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
興味深い。ローカルでは適切に実行する必要はありませんでしたが、実際にはこのトリックがありました。この場合、ローカルとリモートヒーローの差異に関する考えはありますか?さらに、 'package.json'に通常追加するバージョン情報のリストを、単に' npm ls'とすれば、どうやって簡単に作成できますか? 'package.json'を効率的にアセンブルする考えを得ようとしています。 – ylluminate
あなたのExpressがあなたのコンピュータにグローバルにインストールされているかもしれませんか? npm install express -gはそれを行います。 npm lsは問題ありません。私はpackage.jsonのリファレンスとしてhttp://package.json.nodejitsu.com/を使用しています。 – Mustafa
+1これは私のアプリがherokuで動かない理由です。私はpackage.jsonに依存関係としてリストされているすべての必須モジュールを持っていませんでした – user3616725