在Windows_NT 6.1.7600 (x86)中,使用node-gyp构建bcrypt模块出错。

7

我发现很多类似这个问题的答案,但是它们都不能解决我的问题。这是我安装的版本:

node 0.10.31
npm 1.4.23
node-gyp 0.10.31
bcrypt 0.7.8 

我需要在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.

我需要安装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.  

我不得不安装Visual Studio 2008(专业版),这是我手头唯一的版本。然后我添加了PATH变量C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages,其中包含vcbuild.exe

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  

似乎是使用了.NET 4,但失败了。我在 C:\Windows\Microsoft.NET\Framework 目录下有六个.NET框架文件夹,看起来是使用最新的一个:

  • v1.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

6) 尝试使用 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.

对此有什么想法吗?

1个回答

6

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

enter image description here

构建过程似乎正在寻找 [Drive]:\Program Files\Microsoft Visual Studio 10.0\VC\vcpackages\vcbuild.dll,它是由Visual Studio C++ 2010 Express安装的。

首先,我安装了 Microsoft Visual Studio C++ 2012/13 for Windows Desktop,这是Windows7 / 8的要求之一。但其实它不起作用,对于Windows 7来说也不需要它。

结论

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

  • Python v2.7.3(不支持v3.x.x)
  • Windows XP / Vista / 7:
    • Microsoft Visual Studio C++ 2010(Express 版本运行良好)
    • 对于node和本地模块的64位构建,您还需要 Windows 7 64位 SDK
      • 如果安装失败,请尝试先卸载任何已安装的C ++ 2010 x64&x86 Redistributable。
    • 如果出现64位编译器未安装的错误,您可能还需要 Windows SDK 7.1的编译器更新
  • Windows 7/8:
    • Microsoft Visual Studio C++ 2012/13 for Windows Desktop(Express 版本运行良好)

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

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接