[英]Node.js app works on foreman but not heroku. 404 Error
I'm using Yeoman/bower/grunt to build an angular app. 我正在使用Yeoman / bower / grunt构建一个角度应用程序。 The app runs perfectly on foreman.
该应用程序在领班完美运行。 In my search of similar questions on stack most other people just forgot to create their Procfile or had mistakes in their app.js which ran the app.
在我搜索堆栈上的类似问题时,大多数其他人只是忘记创建他们的Procfile或者在运行应用程序的app.js中出错。 But I have both of those and I can't figure out what's wrong with them, such that foreman works and not heroku.
但我有这两个,我无法弄清楚他们有什么问题,这样工头工作而不是heroku。 When I deploy to heroku and open it I get this in the log:
当我部署到heroku并打开它时,我在日志中得到了这个:
2013-10-02T19:33:56.159151+00:00 heroku[api]: Deploy b417d22 by richardadavila@gmail.com
2013-10-02T19:33:56.202052+00:00 heroku[api]: Release v10 created by richardadavila@gmail.com
2013-10-02T20:38:51.350572+00:00 heroku[web.1]: Idling
2013-10-02T20:38:57.626159+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-10-02T20:39:02.097317+00:00 heroku[web.1]: State changed from up to down
2013-10-02T20:39:02.079612+00:00 heroku[web.1]: Process exited with status 143
2013-10-02T22:00:00.360769+00:00 heroku[web.1]: Unidling
2013-10-02T22:00:00.361135+00:00 heroku[web.1]: State changed from down to starting
2013-10-02T22:00:04.049439+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-10-02T22:00:06.128657+00:00 app[web.1]: server started 40741
2013-10-02T22:00:06.164522+00:00 heroku[web.1]: State changed from starting to up
2013-10-02T22:00:07.479644+00:00 heroku[router]: at=info method=GET path=/ host=rickydavila-kpopbetter-s.herokuapp.com fwd="71.144.19.194" dyno=web.1 connect=9ms service=30ms status=404 bytes=22
No error (I probably don't fully understand the log), it just kills the app. 没有错误(我可能不完全理解日志),它只是杀了应用程序。
My Procfile says: "node app.js" 我的Procfile说:“node app.js”
My app.js file that creates an express server to run the app is: 我的app.js文件创建了一个运行应用程序的快速服务器:
var express = require('express');
var path = require('path');
var app = express();
app.configure(function(){
'use strict';
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, 'dist')));
});
var port = process.env.PORT || 5000;
app.listen(port, function() {
'use strict';
console.log('server started '+port);
});
Grunt builds the app to my dist folder which I reference above. Grunt将应用程序构建到我上面引用的dist文件夹中。 Any clear mistakes above?
上面有明显的错误吗? When I open the heroku app url, the page states: Cannot GET /
当我打开heroku app url时,该页面指出: 无法获取/
Oh I also have scaled the dynos as some other questions failed to do. 哦,由于其他一些问题未能做到,我也已经缩放了dynos。 And to my knowledge I'm not hardcoding the port.
据我所知,我并没有硬编码端口。
Figured it out. 弄清楚了。 Always check your .gitignore file!
请务必检查您的.gitignore文件! I forgot to remove dist from the file and it hadn't been committed or pushed to heroku.
我忘了从文件中删除dist并且它没有被提交或推送到heroku。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.