Heroku Nodejs无法在启动时启动应用程序

时间:2018-03-20 11:54:09

标签: javascript node.js heroku

这是日志文件:

2018-03-20T11:45:03.569723+00:00 app[web.1]: npm ERR! Exit status 1 
2018-03-20T11:45:03.569953+00:00 app[web.1]: npm ERR! 
2018-03-20T11:45:03.570261+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 
2018-03-20T11:45:03.570109+00:00 app[web.1]: npm ERR! Failed at the webtech_team1@1.0.0 start script.
2018-03-20T11:45:03.575871+00:00 app[web.1]:
2018-03-20T11:45:03.576049+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-03-20T11:45:03.576172+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-03-20T11_45_03_571Z-debug.log 
2018-03-20T11:45:03.636794+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-20T11:45:05.175983+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=webtech-team1.herokuapp.com request_id=c0080960-f377-4e04-ab4f-89dc696b00ee fwd="193.191.150.3" dyno= connect= service= status=503 bytes= protocol=https
2018-03-20T11:45:05.536530+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=webtech-team1.herokuapp.com request_id=e46e00d3-3f8c-4ec1-84ea-9420b08e5e5d fwd="193.191.150.3" dyno= connect= service= status=503 bytes= protocol=https

我的package.json:

{
  "name": "webtech_team1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/CarolineVG/webtech_team1.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/CarolineVG/webtech_team1/issues"
  },
  "homepage": "https://github.com/CarolineVG/webtech_team1#readme",
  "dependencies": {
    "pug": "^2.0.1"
  }
}

我的index.js

const express = require('express')
const bodyParser = require('body-parser');
const app = express();
const pug = require('pug');
var port = process.env.PORT || 3000; //lets the port be set by Heroku

app.set('views', './views');
app.set('view engine', 'pug');

app.use(bodyParser.json() );
// link to css and img
app.use(express.static('./public'));
app.use('/', require('./routes/index') );

app.listen(port, () => console.log('Example app listening on port 3000!')); 

添加了route / index.js文件

const express = require('express')
const router = express.Router();

/* home */
router.get('/', function(req, res){
    res.render('./home', {title: 'Home'}); 
});

/* kweeni */
router.get('/kweeni', function(req, res){
    res.render('./kweeni', {title: 'kweeni'}); 
});

/* wat is */
router.get('/watis', function(req, res){
    res.render('./watis', {title: 'watis'}); 
});

module.exports = router;

我已经查看了此文档(https://github.com/RickWong/react-isomorphic-starterkit/issues/12)并更改了以下内容: - 在package.json中添加启动脚本 - 添加procfile - 更改端口变量

我仍然收到应用程序错误,有人知道什么是错的?提前谢谢!

0 个答案:

没有答案