Heroku应用程序错误heroku打开

时间:2016-09-02 12:30:59

标签: node.js heroku mean-stack

我有点学习平均堆栈,以及扭转它的一切,我之前有一点点角度,当然我知道一些jou和javascript和web开发。但我对heroku和我有点困惑,为什么我的错误:

  

应用程序错误   应用程序中发生错误,无法提供您的页面。请稍后重试。   如果您是应用程序所有者,请检查日志以获取详细信息。

我做了书上描述的步骤:

  

使用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

我使用express来创建一些文件夹并更改代码以使用mvc模式,这里是代码:

app_server控制器Main.js

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

路线index.js

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

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

module.exports = router;

观看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')

观看index.jade

extends layout

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

app.js

这里我改变了路由,他可以使用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;

打包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:抱歉我的英文不好

1 个答案:

答案 0 :(得分:0)

你现在从来没有错误,你在package.json中添加了这个部分:

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

还尝试在Main.js中设置导出而不使用模块:

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

在您的路线中尝试传递应用实例,然后设置您的路线,如:

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

然后在app.js中设置路由app.use('/',routes)而不是这样:

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