bradtraversy / meanauthapp

Complete MEAN stack app with authentication
242 stars 152 forks source link

Crashing server on POST request - PT3 #46

Closed GlasgowSmile04 closed 6 years ago

GlasgowSmile04 commented 6 years ago

Hello,

I followed the tutorial to the T and went through and checked every character of my code / POST request. I am getting the below error in my nodemon console when I try to use postman to POST a new user. I'm at a loss as I'm VERY new to backend, and am assuming that there is something different about the password validation today vs. when the tutorial was created, however I'd like to understand and complete this project nevertheless.

Postman looks like:

"http://localhost:3000/users/register" "{ "name": "John Doe", "email": "johndoe@gmail.com", "username": "John", "password": "123456" };"

Error messages:

""" internal/modules/cjs/loader.js:583 throw err; ^

Error: Cannot find module 'bcrypt' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:20:18) at Object. (/Users/zac/Documents/MEAN/models/user.js:2:16) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:20:18) at Object. (/Users/zac/Documents/MEAN/routes/users.js:5:14) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) [nodemon] app crashed - waiting for file changes before starting... """

** I was getting this (below) error at first, but I went into mongo console and created the db "meanauth" and then the error changed to above. clearly I'm missing something integral. Any pointers would be appreciated.

""" /Users/zac/Documents/MEAN/models/user.js:38 if(err) throw err; ^

Error: Illegal arguments: undefined, string at _async (/Users/zac/Documents/MEAN/node_modules/bcryptjs/dist/bcrypt.js:214:46) at Object.bcrypt.hash (/Users/zac/Documents/MEAN/node_modules/bcryptjs/dist/bcrypt.js:220:13) at bcrypt.genSalt (/Users/zac/Documents/MEAN/models/user.js:37:12) at Immediate. (/Users/zac/Documents/MEAN/node_modules/bcryptjs/dist/bcrypt.js:153:21) at runCallback (timers.js:694:18) at tryOnImmediate (timers.js:665:5) at processImmediate (timers.js:647:5) """

GlasgowSmile04 commented 6 years ago

Issue with not setting up the database before trying to post... closing issue.