2016-01-20 29 views
3

我试图让一个node.js应用程序在最近从Windows 7升级到Windows 10的机器上运行;然而,npm install命令失败试图建立bcrypt扩展时:在Windows 10上构建npm bcrypt包时出错

>npm install 

> [email protected] 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! [email protected] install: `node-gyp rebuild` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] 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 [email protected] 
gyp info using [email protected] | win32 | x64 
gyp info ok 
node-gyp configure 
gyp info it worked if it ends with ok 
gyp info using [email protected] 
gyp info using [email protected] | 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 [email protected] 
gyp info using [email protected] | 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,我应该减少我的损失,并尝试在一个干净的虚拟机中运行构建。有没有人有任何其他建议?

回答

2

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

+1

是的,刚刚更新'package.json'将bcrypt版本更改为'0.8.6',它的工作原理! –

+0

nope'在[email protected]安装脚本'node-gyp rebuild'失败。 – Meeker

0

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

npm install bcryptjs 

这个工程一样bcrypt和之后,你可以安装它,你可以随便去到node_modules并切换到bcrypt的bcryptjs包名。应该在那之后工作。