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!

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 npm Basics (retiring) Installing Packages with npm Installing Local Packages

Steve Mustanski
Steve Mustanski
15,093 Points

Problem installing bcrypt in workspaces

I get the following error when installing bcrypt:

[bcrypt] Success: "/home/treehouse/workspace/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote                           
ā””ā”€ā”€ bcrypt@2.0.1                                                                                                                                

npm WARN enoent ENOENT: no such file or directory, open '/home/treehouse/workspace/package.json'                                                
npm WARN workspace No description                                                                                                               
npm WARN workspace No repository field.                                                                                                         
npm WARN workspace No README data                                                                                                               
npm WARN workspace No license field.  

when I run app.js I get the following error:

bcrypt.genSalt(saltRounds, function(err, salt) {                                                                                                        

ReferenceError: bcrypt is not defined                                                                                                           
    at Object.<anonymous> (/home/treehouse/workspace/app.js:3:1)                                                                                
    at Module._compile (module.js:570:32)                                                                                                       
    at Object.Module._extensions..js (module.js:579:10)                                                                                         
    at Module.load (module.js:487:32)                                                                                                           
    at tryModuleLoad (module.js:446:12)                                                                                                         
    at Function.Module._load (module.js:438:3)                                                                                                  
    at Module.runMain (module.js:604:10)                                                                                                        
    at run (bootstrap_node.js:389:7)                                                                                                            
    at startup (bootstrap_node.js:149:9)                                                                                                        
    at bootstrap_node.js:504:3     

Anyone else run into this and solve it?

1 Answer

Adam Beer
Adam Beer
11,314 Points

I also ran into this bcrypt problem. I solved it, like this:

npm install bcryptjs

var bcrypt = require('bcryptjs');

Hope this help!

Steve Mustanski
Steve Mustanski
15,093 Points

I completely forgot about requiring it. I had to require(bcrypt) though is that is what I installed. It is working now. Thanks!