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

bcrypt library installation error

C:\Users\Ninja\Desktop\npm>npm install  bcrypt

> bcrypt@1.0.2 install C:\Users\Ninja\Desktop\npm\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcryp
t.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bcrypt@1.0.2 and node@6.9.1 (
node-v48 ABI) (falling back to source compile with node-gyp)

C:\Users\Ninja\Desktop\npm\node_modules\bcrypt>if not defined npm_config_node_gy
p (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_m
odules\node-gyp\bin\node-gyp.js" clean )  else (node "" clean )

C:\Users\Ninja\Desktop\npm\node_modules\bcrypt>if not defined npm_config_node_gy
p (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_m
odules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users
\Ninja\Desktop\npm\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name
=bcrypt_lib --module_path=C:\Users\Ninja\Desktop\npm\node_modules\bcrypt\lib\bin
ding --python=C:\Users\Ninja\.windows-build-tools\python27\python.exe --msvs_ver
sion=2015 )  else (node "" configure --fallback-to-build --module=C:\Users\Ninja
\Desktop\npm\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcryp
t_lib --module_path=C:\Users\Ninja\Desktop\npm\node_modules\bcrypt\lib\binding -
-python=C:\Users\Ninja\.windows-build-tools\python27\python.exe --msvs_version=2
015 )

C:\Users\Ninja\Desktop\npm\node_modules\bcrypt>if not defined npm_config_node_gy
p (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_m
odules\node-gyp\bin\node-gyp.js" build --fallback-to-build --module=C:\Users\Nin
ja\Desktop\npm\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcr
ypt_lib --module_path=C:\Users\Ninja\Desktop\npm\node_modules\bcrypt\lib\binding
 )  else (node "" build --fallback-to-build --module=C:\Users\Ninja\Desktop\npm\
node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --modul
e_path=C:\Users\Ninja\Desktop\npm\node_modules\bcrypt\lib\binding )
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.t
argets(64,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140
') cannot be found. To build using the v140 build tools, please install v140 bu
ild tools.  Alternatively, you may upgrade to the current Visual Studio tools b
y selecting the Project menu or right-click the solution, and then selecting "U
pgrade Solution...". [C:\Users\Ninja\Desktop\npm\node_modules\bcrypt\build\bcry
pt_lib.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` fail
ed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:215:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallb
ack-to-build" "--module=C:\\Users\\Ninja\\Desktop\\npm\\node_modules\\bcrypt\\li
b\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\Users
\\Ninja\\Desktop\\npm\\node_modules\\bcrypt\\lib\\binding"
gyp ERR! cwd C:\Users\Ninja\Desktop\npm\node_modules\bcrypt
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-
to-build --module=C:\Users\Ninja\Desktop\npm\node_modules\bcrypt\lib\binding\bcr
ypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Ninja\Desktop\npm\n
ode_modules\bcrypt\lib\binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Ninja\Desktop\
npm\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/chi
ld_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 6.3.9600
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Ninj
a\\Desktop\\npm\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fal
lback-to-build"
node-pre-gyp ERR! cwd C:\Users\Ninja\Desktop\npm\node_modules\bcrypt
node-pre-gyp ERR! node -v v6.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\Ninj
a\Desktop\npm\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcry
pt_lib --module_path=C:\Users\Ninja\Desktop\npm\node_modules\bcrypt\lib\binding'
 (1)
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Ninja\Desktop\
npm\package.json'
npm WARN npm No description
npm WARN npm No repository field.
npm WARN npm No README data
npm WARN npm No license field.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "bcrypt"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@1.0.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@1.0.2 install script 'node-pre-gyp install --fallb
ack-to-build'.
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 bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Ninja\Desktop\npm\npm-debug.log






=======
Node version - 6.9.1
npm version - 3.10.8
======

3 Answers

Keith Kelly
Keith Kelly
21,326 Points

It looks like this is an issue that others are having. There is an open issue posted on the GitHub page with the same error you are receiving. You may want to follow this issue to see what the resolution ends up being.

Seth Kroger
Seth Kroger
56,413 Points

Since it's falling back to building from source installing this first will help greatly:

npm install --global --production windows-build-tools

Installation can take a while, so take a lunch break or what not. From my post here: https://teamtreehouse.com/community/another-way-for-windows-to-install-bcrypt

Seth Kroger, still getting an error after the successfull installation of build tools and python but when I try to install cordova just for testing and it's get installed on my directory and just give me some warnings instead of errors.

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Ninja\Desktop\
npm\package.json'
npm WARN npm No description
npm WARN npm No repository field.
npm WARN npm No README data
npm WARN npm No license field.
Seth Kroger
Seth Kroger
56,413 Points

Those are warnings, not outright errors, but you'd usually start out your project with npm init to create the package.json file.

Roberto Alonso Lozano Peña
Roberto Alonso Lozano Peña
9,706 Points

Instead of using bcrypt, use bcryptjs, I've heard its not as fast, but it works

Here:

https://www.npmjs.com/package/bcryptjs

It has no dependencies, so you shouldn't have any issues.

Thank me later :)