I have an error running my node js program.
This is the error log
TypeError: Cannot set property 'addUser' of undefined
at Object.<anonymous> (C:\Users\Noman.Matin\Desktop\mbk\angularProj3MeanAuth\models\user.js:39:26)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
while running these properties
mongoose.exports.getUserById = function (id, callback) {
User.findById(id, callback);
}
mongoose.exports.getUserByUsername = function (username, callback) {
const query = {
username: username
};
User.findOne(query, callback);
}
mongoose.exports.addUser = function (newUser, callback) {
bcrypt.genSalt(10, (err, salt) => {
bcrypt.hash(newUser.password, salt, (err, hash) => {
if (err) throw err;
newUser.password = hash;
newUser.save(callback);
})
})
}