简体   繁体   English

Heroku应用程序错误Heroku打开

[英]Heroku application error heroku open

im kinda learning the Mean stack, and everything that turn around it, i had a little expirience with angular before, and of course i know something abouyt javascript and web development. 我有点学习了Mean堆栈,以及所有围绕它的东西,我之前对angular有所了解,当然我对JavaScript和Web开发也有所了解。 But im new with heroku and im kinda confused why my i get this error: 但是我与heroku的新手和我有点困惑为什么我我得到这个错误:

Application Error An error occurred in the application and your page could not be served. 应用程序错误应用程序中发生错误,无法提供您的页面。 Please try again in a few moments. 请稍后重试。 If you are the application owner, check your logs for details. 如果您是应用程序所有者,请检查日志以获取详细信息。

i did the steps described on the book: 我做了书上描述的步骤:

getting MEAN with Mongo, express, angular and node 通过Mongo,Express,Angular和Node获得MEAN

Here is my log from heroku that shows the errors but i cant understand very well what they mean, sorry guys but im really a newbie :/

> 2016-09-02T12:00:37.889792+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=shrouded-garden-88708.herokuapp.com re
quest_id=ef9cea17-fd9e-401e-b7e4-1cf7bf5d2ea2 fwd="2.83.58.24" dyno= connect= se
rvice= status=503 bytes=
2016-09-02T12:00:56.881479+00:00 heroku[api]: Starting process with command `rak
e db:migrate` by filipecosta_10@hotmail.com
2016-09-02T12:00:59.200820+00:00 heroku[run.2019]: Awaiting client
2016-09-02T12:00:59.233918+00:00 heroku[run.2019]: Starting process with command
 `rake db:migrate`
2016-09-02T12:00:59.516923+00:00 heroku[run.2019]: State changed from starting t
o up
2016-09-02T12:01:01.250705+00:00 heroku[run.2019]: Process exited with status 12
7
2016-09-02T12:01:01.270229+00:00 heroku[run.2019]: State changed from up to comp
lete
2016-09-02T12:01:15.503673+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-09-02T12:01:17.194538+00:00 heroku[web.1]: Starting process with command `n
pm start`
2016-09-02T12:01:19.940778+00:00 app[web.1]:
2016-09-02T12:01:19.940796+00:00 app[web.1]: > loc8r@0.0.0 start /app
2016-09-02T12:01:19.940797+00:00 app[web.1]: > node ./bin/www
2016-09-02T12:01:19.940798+00:00 app[web.1]:
2016-09-02T12:01:20.279763+00:00 app[web.1]: module.js:327
2016-09-02T12:01:20.279777+00:00 app[web.1]:     ^
2016-09-02T12:01:20.279776+00:00 app[web.1]:     throw err;
2016-09-02T12:01:20.279778+00:00 app[web.1]:
2016-09-02T12:01:20.279779+00:00 app[web.1]: Error: Cannot find module '../contr
ollers/main'
2016-09-02T12:01:20.279779+00:00 app[web.1]:     at Function.Module._resolveFile
name (module.js:325:15)
2016-09-02T12:01:20.279780+00:00 app[web.1]:     at Module.require (module.js:35
3:17)
2016-09-02T12:01:20.279780+00:00 app[web.1]:     at Function.Module._load (modul
e.js:276:25)
2016-09-02T12:01:20.279781+00:00 app[web.1]:     at require (internal/module.js:
12:17)
2016-09-02T12:01:20.279782+00:00 app[web.1]:     at Object.<anonymous> (/app/app
_server/routes/index.js:3:16)
2016-09-02T12:01:20.279782+00:00 app[web.1]:     at Module._compile (module.js:4
09:26)
2016-09-02T12:01:20.279783+00:00 app[web.1]:     at Object.Module._extensions..j
s (module.js:416:10)
2016-09-02T12:01:20.279784+00:00 app[web.1]:     at Module.load (module.js:343:3
2)
2016-09-02T12:01:20.279784+00:00 app[web.1]:     at Function.Module._load (modul
e.js:300:12)
2016-09-02T12:01:20.279785+00:00 app[web.1]:     at Module.require (module.js:35
3:17)
2016-09-02T12:01:20.291267+00:00 app[web.1]:
2016-09-02T12:01:20.313237+00:00 app[web.1]: npm ERR! Linux 3.13.0-93-generic
2016-09-02T12:01:20.313779+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bi
n/node" "/app/.heroku/node/bin/npm" "start"
2016-09-02T12:01:20.314106+00:00 app[web.1]: npm ERR! node v4.5.0
2016-09-02T12:01:20.315029+00:00 app[web.1]: npm ERR! npm  v2.15.10
2016-09-02T12:01:20.315379+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-09-02T12:01:20.315665+00:00 app[web.1]: npm ERR! loc8r@0.0.0 start: `node .
/bin/www`
2016-09-02T12:01:20.315908+00:00 app[web.1]: npm ERR! Exit status 1
2016-09-02T12:01:20.316190+00:00 app[web.1]: npm ERR!
2016-09-02T12:01:20.316464+00:00 app[web.1]: npm ERR! Failed at the loc8r@0.0.0
start script 'node ./bin/www'.
2016-09-02T12:01:20.316739+00:00 app[web.1]: npm ERR! This is most likely a prob
lem with the loc8r package,
2016-09-02T12:01:20.316995+00:00 app[web.1]: npm ERR! not with npm itself.
2016-09-02T12:01:20.317261+00:00 app[web.1]: npm ERR! Tell the author that this
fails on your system:
2016-09-02T12:01:20.317521+00:00 app[web.1]: npm ERR!     node ./bin/www
2016-09-02T12:01:20.317784+00:00 app[web.1]: npm ERR! You can get information on
 how to open an issue for this project with:
2016-09-02T12:01:20.318051+00:00 app[web.1]: npm ERR!     npm bugs loc8r
2016-09-02T12:01:20.318319+00:00 app[web.1]: npm ERR! Or if that isn't available
, you can get their info via:
2016-09-02T12:01:20.318849+00:00 app[web.1]: npm ERR!     npm owner ls loc8r
2016-09-02T12:01:20.318577+00:00 app[web.1]: npm ERR!
2016-09-02T12:01:20.319132+00:00 app[web.1]: npm ERR! There is likely additional
 logging output above.
2016-09-02T12:01:20.324563+00:00 app[web.1]:
2016-09-02T12:01:20.324958+00:00 app[web.1]: npm ERR! Please include the followi
ng file with any support request:
2016-09-02T12:01:20.325214+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-09-02T12:01:20.411685+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-09-02T12:01:20.421165+00:00 heroku[web.1]: Process exited with status 1
2016-09-02T12:01:24.051194+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=shrouded-garden-88708.herokuapp.com request_id=57
100cae-5160-4d51-896a-c6098499d847 fwd="2.83.58.24" dyno= connect= service= stat
us=503 bytes=
2016-09-02T12:01:24.219376+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=shrouded-garden-88708.herokuapp.com re
quest_id=f2bdbe3f-dac9-4831-bba4-4c81e533862a fwd="2.83.58.24" dyno= connect= se
rvice= status=503 bytes=
2016-09-02T12:10:23.795631+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-09-02T12:10:25.543039+00:00 heroku[web.1]: Starting process with command `n
pm start`
2016-09-02T12:10:28.058117+00:00 app[web.1]: > loc8r@0.0.0 start /app
2016-09-02T12:10:28.058105+00:00 app[web.1]:
2016-09-02T12:10:28.058118+00:00 app[web.1]: > node ./bin/www
2016-09-02T12:10:28.058119+00:00 app[web.1]:
2016-09-02T12:10:28.258887+00:00 app[web.1]: module.js:327
2016-09-02T12:10:28.258889+00:00 app[web.1]:     throw err;
2016-09-02T12:10:28.258890+00:00 app[web.1]:     ^
2016-09-02T12:10:28.258890+00:00 app[web.1]:
2016-09-02T12:10:28.258892+00:00 app[web.1]:     at Function.Module._resolveFile
name (module.js:325:15)
2016-09-02T12:10:28.258891+00:00 app[web.1]: Error: Cannot find module '../contr
ollers/main'
2016-09-02T12:10:28.258893+00:00 app[web.1]:     at Function.Module._load (modul
e.js:276:25)
2016-09-02T12:10:28.258893+00:00 app[web.1]:     at Module.require (module.js:35
3:17)
2016-09-02T12:10:28.258894+00:00 app[web.1]:     at require (internal/module.js:
12:17)
2016-09-02T12:10:28.258895+00:00 app[web.1]:     at Object.<anonymous> (/app/app
_server/routes/index.js:3:16)
2016-09-02T12:10:28.258895+00:00 app[web.1]:     at Module._compile (module.js:4
09:26)
2016-09-02T12:10:28.258897+00:00 app[web.1]:     at Module.load (module.js:343:3
2)
2016-09-02T12:10:28.258896+00:00 app[web.1]:     at Object.Module._extensions..j
s (module.js:416:10)
2016-09-02T12:10:28.258897+00:00 app[web.1]:     at Function.Module._load (modul
e.js:300:12)
2016-09-02T12:10:28.268520+00:00 app[web.1]:
2016-09-02T12:10:28.258898+00:00 app[web.1]:     at Module.require (module.js:35
3:17)
2016-09-02T12:10:28.276252+00:00 app[web.1]: npm ERR! Linux 3.13.0-93-generic
2016-09-02T12:10:28.276653+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bi
n/node" "/app/.heroku/node/bin/npm" "start"
2016-09-02T12:10:28.276901+00:00 app[web.1]: npm ERR! node v4.5.0
2016-09-02T12:10:28.277388+00:00 app[web.1]: npm ERR! npm  v2.15.10
2016-09-02T12:10:28.277852+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-09-02T12:10:28.278329+00:00 app[web.1]: npm ERR! Exit status 1
2016-09-02T12:10:28.278146+00:00 app[web.1]: npm ERR! loc8r@0.0.0 start: `node .
/bin/www`
2016-09-02T12:10:28.278515+00:00 app[web.1]: npm ERR!
2016-09-02T12:10:28.278639+00:00 app[web.1]: npm ERR! Failed at the loc8r@0.0.0
start script 'node ./bin/www'.
2016-09-02T12:10:28.278800+00:00 app[web.1]: npm ERR! This is most likely a prob
lem with the loc8r package,
2016-09-02T12:10:28.278919+00:00 app[web.1]: npm ERR! not with npm itself.
2016-09-02T12:10:28.279166+00:00 app[web.1]: npm ERR!     node ./bin/www
2016-09-02T12:10:28.279020+00:00 app[web.1]: npm ERR! Tell the author that this
fails on your system:
2016-09-02T12:10:28.279292+00:00 app[web.1]: npm ERR! You can get information on
 how to open an issue for this project with:
2016-09-02T12:10:28.279425+00:00 app[web.1]: npm ERR!     npm bugs loc8r
2016-09-02T12:10:28.279530+00:00 app[web.1]: npm ERR! Or if that isn't available
, you can get their info via:
2016-09-02T12:10:28.279709+00:00 app[web.1]: npm ERR!
2016-09-02T12:10:28.279877+00:00 app[web.1]: npm ERR!     npm owner ls loc8r
2016-09-02T12:10:28.280024+00:00 app[web.1]: npm ERR! There is likely additional
 logging output above.
2016-09-02T12:10:28.283884+00:00 app[web.1]:
2016-09-02T12:10:28.284074+00:00 app[web.1]: npm ERR! Please include the followi
ng file with any support request:
2016-09-02T12:10:28.284227+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-09-02T12:10:28.405796+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-09-02T12:10:28.367669+00:00 heroku[web.1]: Process exited with status 1

i used express to create some folders and change the code to use the mvc pattern, here is the code: 我用express创建了一些文件夹,并更改了代码以使用mvc模式,这是代码:

app_server controller Main.js app_server控制器Main.js

module.exports.index = function(req, res){
res.render('index', { title: 'Express' });
};

Routes index.js 路由index.js

var express = require('express');
var router = express.Router();
var ctrlMain = require('../controllers/main');

router.get('/',ctrlMain.index);

module.exports = router;

views layout.jade 查看layout.jade

    doctype html
html
  head
    meta(name='viewport', content='width=device-width, initial-scale=1.0')
    title= title
    link(rel='stylesheet', href='/bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/amelia.bootstrap.css')
    link(rel='stylesheet', href='/stylesheets/style.css')
  body
    block content
    script(src='/javascripts/jquery-3.1.0.min.js')
    script(src='/bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js')

views index.jade 观看index.jade

extends layout

block content
  h1= title
  p Welcome to #{title}

app.js app.js

here i changed the routing soo he can use the mvc pattern 在这里,我更改了路由,以便他可以使用MVC模式

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var routes = require('./app_server/routes/index');
var users = require('./app_server/routes/users');

var app = express();

// view engine setup
app.set('views', path.join(__dirname,'app_server','views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/users', users);

// catch 404 and forward to error handlerr
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

module.exports = app;

Package Json 打包杰森

{


"name": "loc8r",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "engines": {
  "node": "~4.5.0",
  "npm": "~2.15.9"
  },
  "dependencies": {
    "body-parser": "~1.15.1",
    "cookie-parser": "~1.4.3",
    "debug": "~2.2.0",
    "express": "~4.13.4",
    "jade": "~1.11.0",
    "morgan": "~1.7.0",
    "serve-favicon": "~2.3.0"
  }
}

Ps: Sorry about my bad english 附:对不起,我的英语不好

You never now where a bug can be, did you add in package.json this section: 您现在再也找不到错误了,您是否在package.json中添加了以下部分:

"engines": {
"node": ">=0.10.28",
"npm": ">=1.4.28"
}

also try setting export without module in Main.js: 还尝试在Main.js中设置不带模块的导出:

exports.index = function(req, res){
    res.render('index', { title: 'Express' });
};

In your routes try passing in the app instance then set your routes like: 在您的路线中尝试传递应用实例,然后将路线设置为:

var ctrlMain = require('../controllers/main');
exports.setIndexRoutes = function (app) {
    app.route('/').get(ctrlMain.index);
};

then in the app.js set routes app.use('/', routes) instead like this: 然后在app.js中设置路由app.use('/',routes)而不是像这样:

 var routes = require('./app_server/routes/index');
 routes.setIndexRoutes(app);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM