собственно вот по этому адресу models/user находится модуль user.js вот код
var crypto = require("crypto");
var mongoose = require("libs/mongoose");
var schema = new Schema({
username:{
type:Stryng,
unique:true,
required:true
},
hashedPassword:{
type:String,
required:true
},
salt:{
type:String,
required:true
},
created:{
type:Date,
default:Date.now
}
});
schema.metods.encryptPassword = function(password){
return crypto.createHmac("sha1",this.salt).update(password).digest('hex');
};
schema.virtual('password')
.set(function(password){
this._plainPassword = password;
this.salt = Math.random();
this.hashedPassword = this.encryptPassword(password);
})
.get(function(){return this._plainPassword});
shema.methods.checkPassword = function (password) {
return this.encryptPassword(password) === this.hashedPassword;
};
exports.User = mongoose.model('User',schema);
вот так пытаюсь использовать в корне основного
var User = require("models/user").User;
var user = new User({
username:"Tester",
password:"test"
});
user.save(function(err,user,affected){
if(err) throw err;
});
собственно вот сама ошибка
module.js:440
throw err;
^
Error: Cannot find module '/models/user'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/www/html/chatnode/createDb.js:1:74)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)