[英]Having issues deploying node api to heroku
我正在尝试为heroku构建节点api。 当我在本地运行它时,初始路由将显示Hello, we are deployed
/wedding
。 route将在psql数据库中显示婚礼中的用户,并且所有操作都可以在本地将json数据显示到屏幕上。 在本地没有错误,因此我将所有内容推送到git,制作了heroku应用程序,然后将所有内容推送到了heroku。 Heroku成功构建了该应用程序,然后当我打开该应用程序时,它将显示此屏幕
这是我的app.js
const express = require('express');
const logger = require('morgan');
const path = require('path');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const cookieParser = require('cookie-parser');
const app = express();
require('dotenv').config();
//middleware
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(methodOverride('_method'));
app.use(cookieParser());
app.use(express.static('public'));
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
})
app.get('/', (req, res) => {
res.send('hello we are deployed');
});
const weddingRoutes = require('./routes/weddingRoutes');
app.use('/wedding', weddingRoutes);
这是我的package.json文件
{
"name": "just_us_api",
"version": "1.0.0",
"description": "",
"main": "app.js",
"engines": {
"node": "8.9.3",
"npm": " 5.5.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"dev": "nodemon app.js",
"debugger": "DEBUG=*:* npm run dev"
},
"repository": {
"type": "git",
"url": "https://github.com/jdiperi88/just_us_api.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.3",
"dotenv": "^4.0.0",
"express": "^4.16.3",
"html-entities": "^1.2.1",
"isomorphic-fetch": "^2.2.1",
"method-override": "^2.3.10",
"morgan": "^1.9.0",
"path": "^0.12.7",
"pg-promise": "^6.10.3"
}
}
我认为您可以从Heroku的仪表板上查看日志详细信息,这是查看错误的最简单方法。 也许您在'/ routes / weddingRoutes'内部的文件中有一些问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.