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

Peter Retvari
seal-mask
.a{fill-rule:evenodd;}techdegree
Peter Retvari
Full Stack JavaScript Techdegree Student 8,392 Points

Couldn't install bcrypt

Hi folks, I couldn't install bcrypt with npm. Also checeked other questions but didn't find ny useful information. Here is my error message:

gyp ERR! build error                                                                                           
gyp ERR! stack Error: `make` failed with exit code: 2                                                          
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)                                                               
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)                                                      
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)                   
gyp ERR! System Linux 3.10.0-862.14.4.el7.x86_64                                                               
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--f
allback-to-build" "--module=/home/treehouse/workspace/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--modul
e_name=bcrypt_lib" "--module_path=/home/treehouse/workspace/node_modules/bcrypt/lib/binding" "--napi_version=3"
 "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"                                  
gyp ERR! cwd /home/treehouse/workspace/node_modules/bcrypt                                                     
gyp ERR! node -v v8.12.0                                                                                       
gyp ERR! node-gyp -v v3.8.0                                                                                    
gyp ERR! not ok                                                                                                
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.                                                                           

npm ERR! code ELIFECYCLE                                                                                       
npm ERR! errno 1                                                                                               
npm ERR! bcrypt@3.0.2 install: `node-pre-gyp install --fallback-to-build`                                      
npm ERR! Exit status 1                                                                                         
npm ERR!                                                                                                       
npm ERR! Failed at the bcrypt@3.0.2 install script.                                                            
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.             

npm ERR! A complete log of this run can be found in:                                                           
npm ERR!     /home/treehouse/.npm/_logs/2018-11-05T09_29_40_029Z-debug.log 

I did every steps like in the video

6 Answers

Adam Beer
Adam Beer
11,314 Points

I am now unhappy because I could not help to you.

Little hungarian: De jól tudod, az a helyes út. Ha előbb importálod és telepíted majd utána mented nem történik semmi, de ha előbb importálod és még a telepítés előtt rámentesz, nagy valószínűséggel rögtön hibát fog dobni, ha pl nodemon-t használsz.

I tried to reproduce your issue. So please follow these steps:

  1. npm cache clean --force
  2. npm init -> Just create a basic package.json file. Press the enter all time.
  3. This is a tricky move, because the first thing doesn't working to me. So these are the moves. npm install bcrypt or npm install bcryptjs
  4. If you use the bcryptjs then you can modify your code.
var bcrypt = require('bcrypt');

to

var bcrypt = require('bcryptjs');

I hope now your code working fine! :)

Adam Beer
Adam Beer
11,314 Points

Now my bcrypt working to me.

  1. npm install node-pre-gyp
  2. npm install node-pre-gyp install --fallback-to-build
  3. npm install node
  4. npm install bcrypt

The npm has installed bcrypt for me but the console isn't very clean.

I hope one of them works fine to you!

Andrii Kodola
seal-mask
.a{fill-rule:evenodd;}techdegree
Andrii Kodola
Full Stack JavaScript Techdegree Student 16,870 Points

Tried a lot of different options. Seems like bcryptjs is the only solution for me. Also due to a "This version of Node.js requires NODE_MODULE_VERSION xx" error that occurred in the terminal. If anyone will use bcryptjs instead of bcrypt don't forget to copy the code from corresponding README file.

Julianna Kahn
Julianna Kahn
20,702 Points

After much frustration, you solved my problem Adam. I am truly grateful.

Adam Beer
Adam Beer
11,314 Points

Just a tip. First, to get started with NPM the first thing to do is in the console write npm init. tThis will create a package.json file and from there you can install packages like from the videos. Second, now write in the console npm install bcrypt. What happends?

Adam Beer
Adam Beer
11,314 Points

I remembered how I did it. Please just try this, npm install bcryptjs and modify your code:

var bcrypt = require('bcrypt');

to

var bcrypt = require('bcryptjs');

Hope this help!

Shane Pagnatta
Shane Pagnatta
6,681 Points

This worked for me as well! Thanks Adam


Adam Beer on Nov 6

Now my bcrypt working to me.

npm install node-pre-gyp npm install node-pre-gyp install --fallback-to-build npm install node npm install bcrypt The npm has installed bcrypt for me but the console isn't very clean.

I hope one of them works fine to you!

The Following Solution worked for my install in the console. Thanks Adam Beer

Now my bcrypt working to me.

npm install node-pre-gyp npm install node-pre-gyp install --fallback-to-build npm install node npm install bcrypt

Adam Beer
Adam Beer
11,314 Points

I'm glad if I can help to you! Happy Coding!

Peter Retvari
seal-mask
.a{fill-rule:evenodd;}techdegree
Peter Retvari
Full Stack JavaScript Techdegree Student 8,392 Points

Wow thanks Adam. Köszi szépen! Mindjárt kipróbálom és visszaírok. Amúgy a modult nem akkor kell importálni amikor már felinstalláltam?

Adam Beer
Adam Beer
11,314 Points

Oh, bad news, then please working with your personal IDE.