Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript User Authentication With Express and Mongo What is Authentication? Setting Up the Project

npm start failing on my machine.

when i run npm start after i run npm install it keeps failing. I checked if i have the latest version of npm and node on my computer and i do. this is the error message

$ npm start

treehouse-express-auth@1.0.0 start C:\Users\mdong\Desktop\JavaScript-user-auth-express\complete node ./app

open() is deprecated in mongoose >= 4.11.0, use openUri() instead, or set the useMongoClient option if using connect() or createConnection() module.js:340 throw err; ^

Error: Cannot find module 'bcrypt' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:289:25) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (C:\Users\mdong\Desktop\JavaScript-user-auth-express\complete\models\user.js:2:14) at Module._compile (module.js:425:26) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (C:\Users\mdong\Desktop\JavaScript-user-auth-express\complete\routes\index.js:3:12) at Module._compile (module.js:425:26) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (C:\Users\mdong\Desktop\JavaScript-user-auth-express\complete\app.js:42:14) at Module._compile (module.js:425:26) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32)

npm ERR! Windows_NT 10.0.15063 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start" npm ERR! node v5.1.0 npm ERR! npm v3.3.12 npm ERR! code ELIFECYCLE npm ERR! treehouse-express-auth@1.0.0 start: node ./app npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the treehouse-express-auth@1.0.0 start script 'node ./app'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the treehouse-express-auth package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node ./app npm ERR! You can get their info via: npm ERR! npm owner ls treehouse-express-auth npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! C:\Users\mdong\Desktop\JavaScript-user-auth-express\complete\npm-debug.log

Hi, can you copy + paste your package.json? Please refer to the Markdown Cheatsheet display it in a nice readable way.

6 Answers

Apparently the api for bcrypt is the same for an almost identical module called bcryptjs, maybe that would work just fine for doing the treehouse course? Looks like bcrypt can be a headache to install on windows because of dependencies, but bcryptjs is entirely javascript, so it's slower, but installable. https://stackoverflow.com/questions/14573488/error-compiling-bcrypt-node-js

Hope this was the comment that helped!

Yes it did. All i had to do was npm install bcryptjs and then go into the models folder and navigate into the user.js file and change it to require bcryptjs and done. : )

{ "name": "treehouse-express-auth", "version": "1.0.0", "description": "A project for learning how to add authentication to a web application.", "author": "Treehouse Island, Inc.", "private": true, "scripts": { "start": "node ./app" }, "dependencies": { "bcrypt": "^0.8.7", "body-parser": "^1.13.3", "connect-mongo": "^1.2.1", "express": "^4.15.3", "express-session": "^1.13.0", "mongoose": "^4.5.0", "pug": "^2.0.0-beta2" }, "license": "MIT" }

hmmm is bcrypt showing up in your node_modules folder?

nope. i checked the npm bcrypt page and for the prereqs., in able to use bcrypt, I needed to do all these steps to my machine and i wasn't too sure on it. Also i tried installing bcrypt by running npm install bcrypt, but i get the same results.

Apparently the api for bcrypt is the same for an almost identical module called bcryptjs, maybe that would work just fine for doing the treehouse course? Looks like bcrypt can be a headache to install on windows because of dependencies, but bcryptjs is entirely javascript, so it's slower, but installable. https://stackoverflow.com/questions/14573488/error-compiling-bcrypt-node-js

You're the best!! Thanks man.

I can't best answer you because you commented, not answered, but if you change that I'll mark you up. thanks again.