我遇到错误-
Error: Failed to lookup view "location.ejs" in views directory
"e:\NodeJs_Project\geolocationProject\views"
at Function.render
请帮助解决该错误。
server.js
var express = require('express');
var app = express();
const path = require('path');
//Middleware express. For session also.
var expressJwt = require('express-jwt');
var session = require('express-session');
var restify = require('restify');
var bodyParser = require('body-parser');
var mysql = require('mysql');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static ('public'));
var cors = require('cors') // Not required.
app.use(cors());
app.use(express.static('public'))
app.set('views',path.join(__dirname+'/views'));
app.engine('ejs', require('ejs').renderFile);
app.set('view engine', 'ejs');
app.get('/', function(req, res) {
res.render('location.ejs');
});
app.listen(8080,(req,res)=>{
console.log('server running on port 8080')
})
我什至尝试-
app.set('views',__dirname +'/ views /');
和
app.set('views',__dirname +'views');
但无济于事
NodeJs_Project ..geolocationProject ..意见 ..location.ejs