我目前正在学习Express(+ Node.js),我遇到了一个奇怪的错误:
Error: Failed to lookup view "index" in views directory "../NODE_tests/Tutorial/app/views"
我在../ NODE_tests / Tutorial / app / views
中有一个index.jadedoctype 5
html
body
h1 Hellow World!
我的app.js(应该)是正确的:
// require the stuff we need
var express = require("express");
var logger = require("morgan");
var http = require('http');
// build the app
var app = express();
// Set the view directory to /views
app.set('views', __dirname + '/views');
// Let's use the Jade templating language
app.set('view engine', 'jade');
// Logging middleware
app.use(logger('combined'));
app.all('*', function (request, response, next) {
response.writeHead(200, { 'Content-Type': 'text/plain'});
next();
});
// Express routing system ...
app.get('/', function (request, response) {
response.render('index');
});
app.get('*', function (request, response) {
response.end('404 error! Page not found \n');
});
// start it up !
http.createServer(app).listen(8080, '127.0.0.1');
正在运行节点app.js引发了这个错误......我哪里错了?
答案 0 :(得分:1)
因为未清除原因,index.jade文件名为index.jade.log,但.log是不可见的...(从另一个文件复制粘贴......) 抱歉这个不必要的问题......
使用文件
上的OSX信息发现它