Ich versuche, nodejs in Ubuntu 16.04 zu verwenden, und ich installierte Knoten und npm, aber ich habe diesen Fehler "TypeError: Kann die Eigenschaft '_locals' von undefined nicht lesen, wenn ich es versuche dies:TypeError: Kann die Eigenschaft '_locals' von undefined nicht lesen
var express = require("express");
app = express();
bodyParser = require("body-parser");
mongoose = require("mongoose");
app.set("view engine", "ejs");
app.get("/", function(req,res){
app.render("index");
});
app.listen(3000, function(){
console.log("Server Started!");
})
es gibt im Terminal:
Server Started!
TypeError: Cannot read property '_locals' of undefined
at EventEmitter.render (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/application.js:548:11)
at /home/luis/Documents/work/webdevBootcamp/test/app.js:9:6
at Layer.handle [as handle_request] (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/layer.js:95:5)
at next (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/layer.js:95:5)
at /home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/index.js:330:12)
at next (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/index.js:271:10)
at expressInit (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/middleware/init.js:33:5)
at Layer.handle [as handle_request] (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/index.js:312:13)
at /home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/index.js:330:12)
at next (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/router/index.js:271:10)
at query (/home/luis/Documents/work/webdevBootcamp/test/node_modules/express/lib/middleware/query.js:44:5)
wenn ich laden localhost: 3000 wird es keine ejs Datei machen oder lassen sie mich die send() Funktion es ich
app.get("/", function(req,res){
app.send("whatever");
});
heißt es:
TypeError: app.send is not a function
habe ich ausdrücklich und ejs Module installiert (RAN installieren npm -S i ejs Mungo Körper-Parser exprimieren)
könnten Sie bitte überprüfen http://stackoverflow.com/questions/36013826/what-does-typeerror-cannot-read -property-locals-of-undefined-mean for help – nivendha
Sie sollten app.send statt res.send nicht aufrufen. Eine App ist ein Objekt zum Weiterleiten der http-Anfrage. – digit
@digit DANKE! Wow, ich fühle mich dumm – LuisEgan