Skip to content

Loading…

npm install bcrypt fails on Windows 7 with node.js 64bit #98

Closed
dhodgin opened this Issue · 23 comments
@dhodgin

I have bcrypt 0.7.1 building on two computers running windows 7 now.

The following setup WORKS:
Windows 7 ultimate 64bit service pack 1
Python 2.7.3 64bit (python-2.7.3.amd64.msi)
VC 2008 redistributables 32 bit (vcredist_x86.exe)
Visual studio 2010 c# and c++ environments installed
Win32OpenSSL-1_0_1c.exe
Node.js 0.8.5 or 0.8.6 32bit

The following setup does NOT WORK:
Windows 7 ultimate 64bit service pack 1
Python 2.7.3 64bit (python-2.7.3.amd64.msi)
VC 2008 redistributables 32 bit (vcredist_x86.exe)
Visual studio 2010 c# and c++ environments installed
Win32OpenSSL-1_0_1c.exe
Node.js 0.8.5, 0.8.6 64bit

When building with 64 bit node.js version 0.8.6 I get the following linker errors

Daniel@DANIEL-LAPTOP ~/Dropbox/wwwroot (master)
$ npm install bcrypt
npm WARN package.json development@0.0.3 No README.md file found!
npm WARN package.json jade@0.26.3 No README.md file found!
npm WARN package.json mongodb@1.0.2 No README.md file found!
npm WARN package.json passport@0.1.9 No README.md file found!
npm WARN package.json passport-local@0.1.3 No README.md file found!
npm WARN package.json stylus@0.27.1 No README.md file found!
npm http GET https://registry.npmjs.org/bcrypt
npm http 304 https://registry.npmjs.org/bcrypt
npm http GET https://registry.npmjs.org/bindings/1.0.0
npm http 304 https://registry.npmjs.org/bindings/1.0.0

bcrypt@0.7.1 install C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt
node-gyp rebuild

C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt>node "c:<b>Program Files\nodejs\node_modules\npm
\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild
gyp http GET http://nodejs.org/dist/v0.8.6/node-v0.8.6.tar.gz
gyp http 200 http://nodejs.org/dist/v0.8.6/node-v0.8.6.tar.gz
gyp http GET http://nodejs.org/dist/v0.8.6/node.lib
gyp http GET http://nodejs.org/dist/v0.8.6/x64/node.lib
gyp http 200 http://nodejs.org/dist/v0.8.6/node.lib
gyp http 200 http://nodejs.org/dist/v0.8.6/x64/node.lib
blowfish.cc
bcrypt.cc
..\src\bcrypt.cc(232): warning C4267: '=' : conversion from 'size_t' to 'unsigned char', possible loss of data [C:\User
s\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
bcrypt_node.cc
c:\users\daniel.node-gyp\0.8.6\src\node_object_wrap.h(57): warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Per
sistent' needs to have dll-interface to be used by clients of class 'node::ObjectWrap' [C:\Users\Daniel\development\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
with
[
T=v8::Object
]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): warning C4530: C++ exception handler used,
but unwind semantics are not enabled. Specify /EHsc [C:\Users\Daniel\Dropbox\wwwroot\node_module
s\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(211): warning C4244: 'argument' : conversion from 'ssize_t' to 'unsigned char', possible loss of
data [C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(278): warning C4244: 'argument' : conversion from 'const ssize_t' to 'unsigned char', possible lo
ss of data [C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(361): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data [C
:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(362): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data [C
:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) d
oes not match the Linker's OutputFile property value (.node). This may cause your project to build incorrectly. To corr
ect this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in
%(Link.OutputFile). [C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj
]
Creating library C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\Release\bcrypt_li
b.lib and object C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\Release\bcrypt_lib.e
xp
bcrypt_node.obj : error LNK2001: unresolved external symbol RAND_bytes [C:\Users\Daniel\Dropbox\w
wwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
bcrypt_node.obj : error LNK2001: unresolved external symbol CRYPTO_set_id_callback [C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
bcrypt_node.obj : error LNK2001: unresolved external symbol CRYPTO_num_locks [C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
bcrypt_node.obj : error LNK2001: unresolved external symbol CRYPTO_set_locking_callback [C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
bcrypt_node.obj : error LNK2001: unresolved external symbol RAND_pseudo_bytes [C:\Users\Daniel\Dropbox\Fivel dev\develo
pment\wwwroot\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\Release\bcrypt_lib.node : fatal error L
NK1120: 5 unresolved externals [C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt\build\bcrypt_
lib.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:2
15:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:674:10)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuil
d"
gyp ERR! cwd C:\Users\Daniel\Dropbox\wwwroot\node_modules\bcrypt
gyp ERR! node -v v0.8.6
gyp ERR! node-gyp -v v0.6.3
gyp ERR! not ok
npm ERR! bcrypt@0.7.1 install: node-gyp rebuild
npm ERR! cmd "/c" "node-gyp rebuild" failed with 1
npm ERR!
npm ERR! Failed at the bcrypt@0.7.1 install script.
npm ERR! 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-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "c:\Program Files\nodejs\node.exe" "c:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "
install" "bcrypt"
npm ERR! cwd C:\Users\Daniel\Dropbox\wwwroot
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\Daniel\Dropbox\wwwroot\npm-debug.log
npm ERR! not ok code 0

Daniel@DANIEL-LAPTOP ~/Dropbox/wwwroot (master)
$

You can install 2 versions of node.js both the 32 bit and 64bit and change the path that points to which version of node.js you want to test both architectures. I had both 64 and 32 bit node.js installed and when i changed my path to point to:
c:\Program Files (x86)\nodejs
instead of
c:\Program Files\nodejs

It built no problem.

@TooTallNate
Collaborator

You need to install the 64-bit Windows SDK, as outlined in the node-gyp readme: https://github.com/TooTallNate/node-gyp/#installation

@dhodgin

ok thanks. will try this now on a 64 bit node install

@nathanghart

Windows 7 pro 64bit
Python 2.7.3 64bit
Visual studio 2010 c# and c++ environments installed
Win32OpenSSL-1_0_1c.exe
Node.js 0.8.8,64bit

I also installed the 64bit Windows SDK but I still get the exact error as above?

Any suggestions?

@dhodgin

I still have not gotten it to work in a 64 bit environment. I got busy with other things and when I tried to install the 64 bit SDK mentioned above it fails to install on two different machines with unknown errors. At that point I just gave up and went to work on some other things and figured I will come back to it in a few weeks.

If I ever get it working successfully on more than 1 64 bit environment I'll report back.

@weareu

The reason is because the you need Win64OpenSSL, you can find it at the same download. But thats not enough, you need to hack the install a bit. So after it installed, copy the default folder C:\OpenSSL-Win64, and rename your copy to OpenSSL-Win32, make sure to uninstall Win32OpenSSL first though.

You know of-course why this happens, issues with the gyp file and hardcoded location for OpenSSL. TooTallNate, please re-open and lets see if someone can fix that for us.

@TooTallNate TooTallNate added a commit that referenced this issue
@TooTallNate TooTallNate binding: use a good default when building a 64-bit version on Windows
Also allow the "openssl_root" variable to be overridden via the command line:

  $ npm install bcrypt --openssl_root="Z:/network-drive/openssl"

Addresses #98, specifically this comment:

  #98 (comment)
4a4f0dd
@TooTallNate
Collaborator

@weareu Yikes, that's a nasty workaround! I just hopefully pushed a fix for that in 4a4f0dd (I haven't tested it, I'm hoping you could). It makes it so that when building for a 64-bit node, it will look in the C:\OpenSSL-Win64 dir by default. On 32-bit builds the same original directory will be used by default.

With this commit you also have the possibility of overriding the "openssl_root" variable at install-time, something like this:

$ npm install bcrypt --openssl-root="C:\some\other\path\to\openssl"

@weareu If you install from the master branch instead of from the npm repo, you should see these differences. Let me know how they work out!

@weareu

Hey @TooTallNate it works perfectly (to include the right libs that is), but both that and my workaround does not seem to work as node still keeps telling me "The specified module could not be found.", bcrypt_lib is there in the right folder so it must be some x64 dependency that it is missing/can't locate, but building fine without. I'll let you know if I find something.

@weareu

@TooTallNate sorry that was just me not installing the OpenSSL dll's to system directory and not including bin in path. I was getting confused somewhere along the way, lol, it worked fine earlier. So yes, conclusion is Master works 100%.

@TooTallNate
Collaborator

@ncb000gt We should publish a new version for these binding.gyp file changes soon!

@ncb000gt
Owner
@ncb000gt
Owner

New version is published. Thanks.

@dhodgin

I'll test this on Win Server2008 R2 64bit system later this week

@ncb000gt
Owner

Great thanks!

@JohnMcLear

I stumbled across this issue today. SDK wont install for me, the Windows SDK is a cancer on a machine too, I will do everything I can to avoid installing it.

I'm going to look around for a Win64OpenSSL package I can deploy. Will post my updates in the comments.

I grabbed https://fcuk-wow.googlecode.com/files/Win64OpenSSL-1_0_0e.exe and installed that.

I still get an error:

C:\temp\primarywall>npm install bcrypt --openssl-root="c:\OpenSSL-Win64"
npm http GET https://registry.npmjs.org/bcrypt
npm http 304 https://registry.npmjs.org/bcrypt
npm http GET https://registry.npmjs.org/bindings/1.0.0
npm http 304 https://registry.npmjs.org/bindings/1.0.0

> bcrypt@0.7.2 install C:\temp\primarywall\node_modules\bcrypt
> node-gyp rebuild


C:\temp\primarywall\node_modules\bcrypt>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
C:\temp\primarywall\node_modules\bcrypt\build\bcrypt_lib.vcxproj(1,638): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the  declaration is correct, and that th
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:219:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:91:17)
@ncb000gt
Owner

I suspect that the file which isn't found is placed there by the SDK? Assuming that is the case, and that it is needed for the build, you'll either have to figure out how to get the file there or make the build process work without depending on it.

I'm not sure whether either of these would work.

@weareu

@johnyma22 there seems to be something wrong with your VCTargetsPath environment variable, or you don't have MSBuild installed (hence the SDK), alternatively you can also install a Visual Studio Express version (c++), that should also work fine, but you need VC++ compilers to build on windows until prebuilt binaries get included.

@weareu

Maybe one day someone really really bored and/or annoyed, because brypt again doesn't build on windows/something else, will fork and create a pure node blowfish implementation, maybe porting http://code.google.com/p/javascript-bcrypt/ which should be pretty easy as it supports the whole lot, but somewhat slower, thinking acceptably though, hint hint at someone with more time (@ncb000gt ???)

@defunctzombie
Collaborator

I am not sure anyone on the project currently has time (or interest) in making this work on windows and certainly not with porting to pure node. I also don't think that the above pure javascript implementation is properly following the license of the projects it uses code from.

As you say, unless some one comes along and provides a very clear way of making this work on windows (and possibly adds it to the wiki) I think we can remove the windows support from the readme. It seems a bit misleading to users to say we support windows but then have no real support (since none of us seem to run it) and provide no really good way to make it work on windows for these various environments. I am not against having windows support, I just think we need to have whomever has it working document their setup so that others can replicate that. It seems that the windows space has a lot more variety with how things can be installed and where they live.

This is an action call for anyone who uses this on windows to populate this wiki (https://github.com/ncb000gt/node.bcrypt.js/wiki/windows-support) with their guide so that we can work on guiding users a bit better.

@ncb000gt
Owner

As far as I'm aware, although I could be wrong, the random generation in JS is insufficient for seeding anything security related. As such you'll always have a dependency on something native...we could probably get around that by gaining access to node's openssl support...but still, it has a native dep.

As for the windows support bit. I'm fine with leaving it in the readme as some people have successfully gotten it working with the existing code base. It seems, as you noted @shtylman, we need clearer instructions. So, that wiki page would be a good starting point. Have at it windows users. ;D

On that note, I'd be interested in adding a committer that does use windows regularly and can hack them some C/C++. Shoot me an email if you're interested.

@mrcsparker

Make sure that c:\OpenSSL-Win64\bin is in your PATH

This fixed it for me

@hamsterready

Thanks @mrcsparker - this worked for me as well.

@Shekharrajak

You need to install python >=2.5 and <3.0 version
To switch your python version install that version then create symbolic link between current version and this version .
command :
As root:
ln -sf /usr/bin/python2.6 /usr/local/bin/python
This will make a symbolic link from c:/python c:/python (replacing the old hardlink).

and need to install other dependencies for node-gyp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.