【问题标题】:node-gyp build error for bcrypt module in Windows_NT 6.1.7600 (x86)Windows_NT 6.1.7600 (x86) 中 bcrypt 模块的 node-gyp 构建错误
【发布时间】:2015-01-18 00:27:07
【问题描述】:

我找到了很多类似这个问题的答案,但他们都无法解决我的问题。这是我安装的版本:

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(专业版),这是我手中唯一的一个。我在 vcbuild.exe 所在的位置添加了 PATH 变量 C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages

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 重建

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.

对此有什么想法吗?

【问题讨论】:

    标签: node.js windows-7 node-gyp


    【解决方案1】:

    我关注the Windows installation step for node-gyp 并安装Microsoft Visual Studio C++ 2010 Express 解决了这个问题,除了一些警告。我确实在控制台消息中看到了创建的库。

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

    首先我安装了Microsoft Visual Studio C++ 2012/13 for Windows Desktop,这是Windows7/8 的要求之一。 但实际上并没有用,Windows 7 也不需要

    结论

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

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

    这不仅是bcrypt 的要求,而且是所有需要使用node-gyp 构建的节点模块。如果你检查一个模块的配置文件,你会看到它的需求,例如,你可以检查以下文件:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-28
      • 2015-09-27
      • 2018-09-03
      • 1970-01-01
      • 2020-04-10
      相关资源
      最近更新 更多