在Windows 10上构建npm bcrypt包时出错

时间:2016-01-20 17:37:12

标签: msbuild npm windows-10 node-gyp

我正在尝试在最近从Windows 7升级到Windows 10的计算机上运行node.js应用程序;但是,npm install命令在尝试构建bcrypt扩展名时失败:

>npm install

> bcrypt@0.8.2 install C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt
> node-gyp rebuild


>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  blowfish.cc
  bcrypt.cc
  bcrypt_node.cc
..\src\bcrypt.cc(232): warning C4267: '=': conversion from 'size_t' to 'unsigned char', possible loss of data [C:\Users\ken\Documents\Projects\node.j
s\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
c:\users\ken\documents\projects\node.js\node-app\node_modules\nan\nan_implementation_12_inl.h(181): error C2660: 'v8::Signature::New': function does not take 4 arguments (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(173): error C2995: 'v8::Local<T> _NanEnsureLocal(v8::Local<T>)': function
 template has already been defined (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(166): note: see declaration of '_NanEnsureLocal' (compiling source file
   ..\src\bcrypt_node.cc)
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(564): error C3083: 'smalloc': the symbol to the left of a '::' must be a type (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj
]
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(564): error C2039: 'FreeCallback': is not a member of 'node' (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\.node-gyp\5.4.1\include\node\node_object_wrap.h(8): note: see declaration of 'node' (compiling source file ..\src\bcrypt_node.cc)
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(564): error C2061: syntax error: identifier 'FreeCallback' (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(568): error C2065: 'callback': undeclared identifier (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(568): error C2065: 'hint': undeclared identifier (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(575): error C2665: 'node::Buffer::New': none of the 4 overloads could convert all the argument types (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\.node-gyp\5.4.1\include\node\node_buffer.h(43): note: could be 'v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate *,char *,size
  _t)' (compiling source file ..\src\bcrypt_node.cc)
  C:\Users\ken\.node-gyp\5.4.1\include\node\node_buffer.h(31): note: or       'v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate *,v8::Local<v
  8::String>,node::encoding)' (compiling source file ..\src\bcrypt_node.cc)
  C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(575): note: while trying to match the argument list '(v8::Isolate *, const char *, uint32_t)' (compiling source file ..\src\bcrypt_node.cc)
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(579): error C2440: 'return': cannot convert from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>' (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(579): note: No constructor could take the source type, or constructor overload resolution was ambiguous (compiling source file ..\src\bcrypt_node.cc)
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(586): error C2039: 'Use': is not a member of 'node::Buffer' (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\.node-gyp\5.4.1\include\node\node_buffer.h(8): note: see declaration of 'node::Buffer' (compiling source file ..\src\bcrypt_node.cc)
C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\nan\nan.h(586): error C3861: 'Use': identifier not found (compiling source file ..\src\bcrypt_node.cc) [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(76): warning C4244: 'argument': conversion from 'ssize_t' to 'unsigned char', possible loss of data [C:\Users\ken\Documents\Pro
jects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(85): warning C4996: 'node::Encode': was declared deprecated [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\
bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\.node-gyp\5.4.1\include\node\node.h(298): note: see declaration of 'node::Encode'
..\src\bcrypt_node.cc(137): warning C4244: 'argument': conversion from 'const ssize_t' to 'unsigned char', possible loss of data [C:\Users\ken\Docume
nts\Projects\node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(139): warning C4996: 'node::Encode': was declared deprecated [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules
\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\.node-gyp\5.4.1\include\node\node.h(298): note: see declaration of 'node::Encode'
..\src\bcrypt_node.cc(172): warning C4996: 'node::Encode': was declared deprecated [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules
\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\.node-gyp\5.4.1\include\node\node.h(298): note: see declaration of 'node::Encode'
..\src\bcrypt_node.cc(223): warning C4996: 'node::Encode': was declared deprecated [C:\Users\ken\Documents\Projects\node.js\node-app\node_modules
\bcrypt\build\bcrypt_lib.vcxproj]
  C:\Users\ken\.node-gyp\5.4.1\include\node\node.h(298): note: see declaration of 'node::Encode'
..\src\bcrypt_node.cc(231): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\ken\Documents\Projects\
node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(232): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\ken\Documents\Projects\
node.js\node-app\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\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:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\ken\Documents\Projects\node.js\node-app\node_modules\bcrypt
gyp ERR! node -v v5.4.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v5.4.1
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@0.8.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.2 install script 'node-gyp rebuild'.
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-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! Please include the following file with any support request:
npm ERR!     C:\Users\ken\Documents\Projects\node.js\node-app\npm-debug.log

nan错误让我怀疑bcrypt扩展程序可能会提取nan软件包的旧版本,但如果我手动安装nan,则错误仍然存​​在

bcrypt包使用node-gyp作为其原生构建基础架构;我有一个list of requirements(除了VS 2015社区版;我有VS 2015专业版)。为了查看我是否可以从源代码构建bcrypt包,我克隆了bcrypt存储库并运行了它的Makefile

>mingw32-make
node-gyp clean
gyp info it worked if it ends with ok
gyp info using node-gyp@3.2.1
gyp info using node@5.4.1 | win32 | x64
gyp info ok
node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.2.1
gyp info using node@5.4.1 | win32 | x64
gyp info spawn F:\python2\python.EXE
gyp info spawn args [ 'C:\\Users\\ken\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ken\\Documents\\Projects\\node.js\\node.bcrypt.js\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ken\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ken\\.node-gyp\\5.4.1\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\ken\\.node-gyp\\5.4.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\ken\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\ken\\Documents\\Projects\\node.js\\node.bcrypt.js',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\ken\\Documents\\Projects\\node.js\\node.bcrypt.js\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok
node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.2.1
gyp info using node@5.4.1 | win32 | x64
gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  blowfish.cc
  bcrypt.cc
  bcrypt_node.cc
..\src\bcrypt.cc(232): warning C4267: '=': conversion from 'size_t' to 'unsigned char', possible loss of data [C:\Users\ken\Documents\Projects\node.j
s\node.bcrypt.js\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(76): warning C4244: 'argument': conversion from 'ssize_t' to 'unsigned char', possible loss of data [C:\Users\ken\Documents\Pro
jects\node.js\node.bcrypt.js\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(229): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\ken\Documents\Projects\
node.js\node.bcrypt.js\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(230): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\ken\Documents\Projects\
node.js\node.bcrypt.js\build\bcrypt_lib.vcxproj]
  win_delay_load_hook.c
kernel32.lib : fatal error LNK1183: invalid or corrupt file: extended relocation count 2848 less than 65535 [C:\Users\ken\Documents\Projects\node.js\
node.bcrypt.js\build\bcrypt_lib.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\ken\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ken\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Users\ken\Documents\Projects\node.js\node.bcrypt.js
gyp ERR! node -v v5.4.1
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
Makefile:11: recipe for target 'compile' failed
mingw32-make: *** [compile] Error 1

有一些转换警告类似于npm构建,但有一个不同的致命错误,这次是在链接器中:kernel32.lib : fatal error LNK1183: invalid or corrupt file: extended relocation count 2848 less than 65535 [C:\Users\ken\Documents\Projects\node.js\node.bcrypt.js\build\bcrypt_lib.vcxproj]

在任何情况下,显而易见的是bcrypt Makefile仅用于引导构建,并且msbuild正在完成繁重的世界。我提取了msbuild命令行并对其进行了修改以生成更详细的日志记录:

> "C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe" build/binding.sln /fl /clp:Verbosity=detailed /nologo /p:Configuration=Release;Platform=x64

当我这样做时,我注意到将LIB环境变量传递给link子进程时出现了一些问题:

Task "SetEnv"
  LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\lib\amd64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64;;;C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x64
Done executing task "SetEnv".

如果您检查这些路径,您会注意到它使用的是Windows 10 SDK(C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64)和Windows 8.1 SDK(C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64)中的目录。这似乎打破了构建;如果我使用设置为Windows 10 SDK的路径手动运行链接器,则会构建它。但是,我不能说服构建过程自己做这件事!我试图通过重命名其注册表项来隐藏8.1 SDK,但没有成功。我也一直试图找出msbuild基础设施中确切设置这些库路径的位置,但再次没有成功。

我自己的预感是,升级到Windows 10已经以某种方式搞砸了msbuild,我应该减少损失并尝试在干净的VM中运行构建。有没有人有其他建议?

2 个答案:

答案 0 :(得分:2)

我有同样的问题,但只是尝试再次安装bcrypt一切正常。 请尝试使用版本0.8.6 希望有帮助。

答案 1 :(得分:0)

这是一种替代解决方案,但您可以改为安装bcryptjs。

strJobname=strJobname.replaceAll("([^_])([A-Z])", "$1 $2");

这与bcrypt的工作方式相同,安装完成后,您可以进入node_modules并将bcryptjs包名更改为bcrypt。应该在那之后工作。