Kürzlich habe ich meinen mongodb-Server vermasselt, aber ich habe ihn repariert und alles läuft glatt außer diesem einen Verzeichnis. Wenn ich Mungo in dieses Verzeichnis NPM installieren zurück, es funktioniert und alles, aber der node_modolus Ordner,NPM installieren Mungo?
door_bells:~/workspace/Associations.1 $ npm install mongoose
[email protected] ../../node_modules/mongoose
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected])
auch Pop-up tut vermuten ist, wenn ich versuche, eine js-Datei in diesem Verzeichnis runnning, ist dies der Fehler, den ich bekommen :
door_bells:~/workspace/Associations $ node embed.js
events.js:141
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'posts' of null
at /home/ubuntu/workspace/Associations/embed.js:56:12
at Query.<anonymous> (/home/ubuntu/node_modules/mongoose/lib/model.js:3327:16)
at /home/ubuntu/node_modules/mongoose/node_modules/kareem/index.js:259:21
at /home/ubuntu/node_modules/mongoose/node_modules/kareem/index.js:127:16
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
var userSchema = new mongoose.Schema({
email: String,
name: String,
posts: [postSchema]
});
var User = mongoose.model('User', userSchema);
User.findOne({name: 'sl'}, function(err,user){
if(err) {
console.log(err);
} else {
user.posts.push({
title: '3 Things i really hate',
content: 'uuK,SyY,x'
});
user.save(function(err,user){ //user save
if(err){
console.log(err);
} else {
console.log(user);
}
});
}
});
Was ist der Code in embed.js? –
hey, Entschuldigung für die späte Antwort, das ist der Code –