我正在按照这里的说明操作: https://scotch.io/tutorials/easy-node-authentication-setup-and-local,当我在尝试运行我的代码时遇到此错误时, 错误:无法在视图目录“目录/视图”中查找视图“index.ej
错误:无法在视图目录“目录/视图”中查找视图“index.ejs”
at EventEmitter.render (Directory/node_modules/express/lib/application.js:579:17) at ServerResponse.render (Directory/node_modules/express/lib/response.js:961:7) at Directory/ourMeanJS/config/routes.js:10:13 at Layer.handle [as handle_request] (Directory/node_modules/express/lib/router/layer.js:95:5) at next (Directory/node_modules/express/lib/router/route.js:131:13) at Route.dispatch (Directory/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (Directory/node_modules/express/lib/router/layer.js:95:5) at Directory/node_modules/express/lib/router/index.js:277:22 at Function.process_params (Directory/node_modules/express/lib/router/index.js:330:12) at next (Directory/node_modules/express/lib/router/index.js:271:10) at Directory/node_modules/connect-flash/lib/flash.js:21:5 at Layer.handle [as handle_request] (Directory/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (Directory/node_modules/express/lib/router/index.js:312:13) at Directory/node_modules/express/lib/router/index.js:280:7 at Function.process_params (Directory/node_modules/express/lib/router/index.js:330:12) at next (Directory/node_modules/express/lib/router/index.js:271:10)
这是我的路线设置:
module.exports = function(app, passport) { // ===================================== // HOME PAGE (with login links) ======== // ===================================== app.get('/', function(req, res) { res.render('index.ejs'); // load the index.ejs file });
这是我的一些server.js:
app.set('view engine', 'ejs'); // set up ejs for templating require('./config/routes.js')(app, passport);
我的观点在目录/视图中,我有一个名为index.ejs的视图.有谁知道出了什么问题?
*编辑刚刚意识到这条路线有效,不知道是否有线索
app.get('/signup', function(req, res) { // render the page and pass in any flash data if it exists res.render('signup.ejs', { message: req.flash('signupMessage')}); });我也有这个问题,我的发现者将文件显示为index.ejs,但它实际上是幕后的index.ejs.html.要在Mac上修复此问题,请右键单击您的文件 – >获取信息 – >并从中删除.html扩展名.