Windows_NT 6.1.7600(x86)中bcrypt模块的node-gyp构建错误

Sit*_*thu 7 windows-7 node.js node-gyp

我找到了许多答案,就像这个问题,但所有这些都无法解决我的问题.这是我安装的版本:

node 0.10.31
npm 1.4.23
node-gyp 0.10.31
bcrypt 0.7.8 
Run Code Online (Sandbox Code Playgroud)

我在package.json中有依赖"bcrypt": "0.7.x".这是我的一步一步:

1)跑 npm install

gyp ERR! stack Error: Can't find Python executable "python", you can
set the PYTHON env variable.
Run Code Online (Sandbox Code Playgroud)

我不得不安装Python 2.7.*

2)跑 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.  
Run Code Online (Sandbox Code Playgroud)

我不得不安装Visual Studio 2008(Professional),这是我手中唯一的.我C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackagesvcbuild.exe中添加了PATH变量.

3)npm install再次运行

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  
Run Code Online (Sandbox Code Playgroud)

它似乎使用.NET 4而失败了.我有六个.NET框架文件夹C:\Windows\Microsoft.NET\Framework,它似乎使用最新的:

  • 1.0.3705
  • V1.1.4322
  • V2.0.50727
  • V3.0
  • V3.5
  • v4.0.30319

4)试过 npm install --msvs_version=2008

(2)相同的错误.

5)试过 npm install --msvs_version=2012

错误改变了一点.

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
Run Code Online (Sandbox Code Playgroud)

6)尝试node-gyp重建

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.
Run Code Online (Sandbox Code Playgroud)

对此有什么想法吗?

Sit*_*thu 6

我按照node-gyp的Windows安装步骤进行操作,安装Microsoft Visual Studio C++ 2010 Express解决了这个问题,除了一些警告.我确实看到了在控制台消息中创建的库.

在此输入图像描述

构建过程似乎在寻找[Drive]:\Program Files\Microsoft Visual Studio 10.0\VC\vcpackages\vcbuild.dllVisual Studio C++ 2010 Express安装的过程.

首先,我为Windows桌面安装了Microsoft Visual Studio C++ 2012/13,这是Windows7/8的要求之一.但它实际上并不起作用,对于Windows 7来说并不是必需的.

结论

Windows 7 32位node-gyp要求(Windows 7/8 64位可能有不同的要求):

  • Python v2.7.3(不支持v3.xx)
  • Windows XP/Vista/7:
    • Microsoft Visual Studio C++ 2010(Express版本运行良好)
    • 对于64位版本的节点和本机模块,您还需要Windows 7 64位SDK
      • 如果安装失败,请尝试卸载先安装的任何C++ 2010 x64和x86 Redistributable.
    • 如果您收到未安装64位编译器的错误,则可能还需要Windows SDK 7.1编译器更新
  • Windows 7/8:
    • 用于Windows桌面的Microsoft Visual Studio C++ 2012/13(Express版本运行良好)

这不仅要求bcrypt,而且需要使用node-gyp构建所有节点模块.如果检查模块的配置文件,您将看到其要求,例如,您可以检查以下文件:

  • \node_modules\bcrypt\build\binding.sln
  • \node_modules\bcrypt\build\config.gypi