req.files.profileimage is not defined. I think this is because i am using the new version of multer
When using new version of multer if you do not upload any file req.file goes undefine and hence gets an error hence in users.js post request of register you should instead of
if(req.files.profileimage)
you replace with try and catch block like
try {
//rest of the code
}catch(e){
var profileImagename = 'noimage.png';
}`