我目前正在設置Heroku部署。當它在本地運行時一切正常,但我從Heroku得到以下錯誤。內部服務器錯誤節點js
at=info method=GET path="/" host=pure-cliffs-68507.herokuapp.com
request_id=66cd6aa8-209d-4065-88ce-ad201ce6e713 fwd="210.86.90.97"
dyno=web.1 connect=0ms service=24ms status=500 bytes=524 protocol=https
2017-07-03T15:05:22.180020+00:00 app[web.1]: GET/500 19ms - 148b
2017-07-03T15:05:22.181519+00:00 app[web.1]: Error: Failed to lookup view " index.html" in views directory "/app"
2017-07-03T15:05:22.181520+00:00 app[web.1]: at EventEmitter.render (/app/node_modules/express/lib/application.js:580:17)
2017-07-03T15:05:22.181521+00:00 app[web.1]: at ServerResponse.render (/app/node_modules/express/lib/response.js:971:7)
2017-07-03T15:05:22.181521+00:00 app[web.1]: at /app/routes.js:8:7
2017-07-03T15:05:22.181522+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2017-07-03T15:05:22.181522+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2017-07-03T15:05:22.181523+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2017-07-03T15:05:22.181523+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2017-07-03T15:05:22.181524+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:281:22
2017-07-03T15:05:22.181525+00:00 app[web.1]: at Function.process_params (/app/node_modules/express/lib/router/index.js:335:12)
2017-07-03T15:05:22.181525+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/index.js:275:10)
我相信它與文件路徑有關。我目前擁有基本目錄(即項目/)中的所有內容,因此正在使用以下內容。
app.use(express.static(path.join(__dirname, '/')));
app.set('views', __dirname);
下面是我的一些GET請求的
app.get('/', function(req, res) {
res.render('index.html');
});
app.get('/browsePage', function(req, res) {
res.render('browsePage.html');
});
感謝您對您的幫助提前。