node-gyp build error for bcrypt module in Windows_NT 6.1.7600 (x86)

node-gyp, node.js, windows-7

Solution

I followed the Windows installation step for node-gyp and installing Microsoft Visual Studio C++ 2010 Express solved the problem except a few warnings. I did see the library created in the console message.

The build process seems looking for `[Drive]:\Program Files\Microsoft Visual Studio 10.0\VC\vcpackages\vcbuild.dll` which is installed by Visual Studio C++ 2010 Express.

Firstly I installed Microsoft Visual Studio C++ 2012/13 for Windows Desktop, one of the requirement for Windows7/8. But it did not work actually and it is not necessary for Windows 7.

Conclusion

The `node-gyp` requirement for Windows 7 32 bits (Windows 7/8 64 bits may have different requirement):

- Python v2.7.3 (v3.x.x is not supported)

- Windows XP/Vista/7:

- Microsoft Visual Studio C++ 2010 (Express version works well)

- For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK

- If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first.

- If you get errors that the 64-bit compilers are not installed you may also need the compiler update for the Windows SDK 7.1

- Windows 7/8:

- Microsoft Visual Studio C++ 2012/13 for Windows Desktop (Express version works well)

This is a requirement not only for `bcrypt`, but all node modules which needs to be built using node-gyp. If you check the configuration files of a module, you will see its requirement, for example, you can check the following files:

- `\node_modules\bcrypt\build\binding.sln`

- `\node_modules\bcrypt\build\config.gypi`

Problem

I found many answers like a kind of this question, but all of them could not solve my problem. Here are my versions installed: ``` node 0.10.31 npm 1.4.23 node-gyp 0.10.31 bcrypt 0.7.8 ``` I have the dependency in package.json `"bcrypt": "0.7.x"`. Here are my step-by-step: 1) Run `npm install` ``` gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. ``` I had to install Python 2.7.* 2) Run `npm install` ``` MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. ``` I had to install Visual Studio 2008 (Professional) which is the only one I had in my hand. And I added the PATH variable `C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages` where vcbuild.exe is. 3) Run `npm install` again ``` VCBUILD : error Message: [D:\...\node_modules\bcrypt\build\binding.sln] VCBUILD : System error : -2147154687. [D:\...\node_modules\bcrypt\build\binding.sln] gyp ERR! build error gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1 ``` It seems using .NET 4 and failed. I have six .NET frameworks folders in `C:\Windows\Microsoft.NET\Framework` and it seems using the latest one: - v1.0.3705 - v1.1.4322 - v2.0.50727 - v3.0 - v3.5 - v4.0.30319 4) Tried `npm install --msvs_version=2008` Same error as (2). 5) Tried `npm install --msvs_version=2012` Error changed a little bit. ``` D:\...\node_modules\bcrypt\build\bcrypt_lib.vcxproj(18,3): error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. gyp ERR! build error gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1 ``` 6) Tried node-gyp rebuild ``` D:\...\node-proj>node-gyp rebuild --msvs_version=2008 'node-gyp' is not recognized as an internal or external command, operable program or batch file. ``` Is there any idea on this?

Original source