Error compiling bcrypt - node.js

Ditch the bcrypt module and use a native JavaScript library instead. bcrypt-nodejs requires no compilation and provides almost the same functionality as the compiled bcrypt.


This is correct way to install bcrypt over npm on Windows 7/8 x64

Pre:

  • install Python http://www.python.org/download/releases/2.7.5/
  • Install Visual Studio 2012/13 Express (or other)
  • Install Windows SDK (for Windows 7 / 8)
  • Install Win64 OpenSSL v1.0.1g

Post:

Open "Developer Command Prompt for VS2012" as Administrator and test install:

npm install node-gyp -g
npm install bcrypt -g

p.s. My current Windows environment: win8 x64, node 0.10.x. All works nice.

UPDATE (2016): Note for Windows 10 x64

Visual Studio Express Desktop Edition solves node-gyp problem. Just install it and it will work for node-gyp.

Links:

  • Microsoft Visual Studio Express 2012 for Windows Desktop
  • Visual Studio Express 2015 Desktop Edition
  • Windows 8 SDK
  • SSL Download
  • node-gyp installation

For anyone still facing errors installing bcrypt in 2017.

An npm module has been released to handle Window's native dependency issues by Felix Rieseberg and other contributors. .NET Framework 4.5.1 is the only requirement for Windows 7 / Vista.

With admin privileges, run:

npm install --g --production windows-build-tools
npm install bcrypt

How I resolved this.

My enviroment: Windows 8.1 x64, Node v0.12.2, npm v2.7.5

Install all components:

  1. Install latest 2.x Python, download Python (I downloaded 2.7.9)
  2. Install Visual Studio 2012/13 Express (or other)
  3. Install Windows SDK (for Windows 7 / 8)
  4. Install Win64 OpenSSL v1.0.1g, download it from here (I loaded "Win64 OpenSSL v1.0.2a" latest)

After all components is installed [Important]:

Open "Developer Command Prompt for VS2012" as Administrator

[for VS 2012] Go to

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools

[for VS 2013] Go to

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools

Execute command "VsDevCmd.bat"

Then you can execute these cmd:

npm install node-gyp -g
npm install bcrypt -g

And for me it worked (I have trouble to launch, because from beginning I no execute command "VsDevCmd.bat").

Note:

  1. If it still not executes try to Execute command in simple Command prompt opened as Administrator
  2. Or if bcrypt is installing successfully and executing npm install in your project it fails. Check bcrypt version in package.json. In my case there was "bcrypt": "0.7.x" dependency was specified, and I have newer bcryot version, so after changind it to "bcrypt": "0.8.x", everything installed successfully.