我下面從這裏說明:https://scotch.io/tutorials/easy-node-authentication-setup-and-local,當我試圖運行我的代碼的時候得到這個錯誤,
無法查找觀點,正確的文件名和位置
Error: Failed to lookup view "index.ejs" in views directory "Directory/views"
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? –
你能告訴我你如何定義視圖目錄嗎? –