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

标签 node.js windows-7 node-gyp

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

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

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.

有什么想法吗?

最佳答案

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

enter image description here

构建过程似乎在寻找由 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 位构建的 Node 和 native 模块,您还需要 Windows 7 64-bit SDK
      • 如果安装失败,请尝试卸载您首先安装的任何 C++ 2010 x64&x86 Redistributable。
    • 如果您遇到未安装 64 位编译器的错误,您可能还需要 compiler update for the Windows SDK 7.1
  • Windows 7/8:
    • 适用于 Windows 桌面的 Microsoft Visual Studio C++ 2012/13(Express 版本运行良好)

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

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

关于node.js - Windows_NT 6.1.7600 (x86) 中 bcrypt 模块的 node-gyp 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27034592/

相关文章:

node.js - 运行 npm install 时出现 node-gyp 错误

node.js - Windows 上的 node-gyp 出现问题 : configure error

node.js - Mongodb 通过对象 ID 在数组中查找文档

ruby - 作为 NodeJS 用户,如何使用 ruby​​ OpenSSL 库进行加密?

.net - 如何获得来自主音频 channel 的当前声音的响度?

java - Selenium 网络驱动程序 : Able to open Firefox browser but unable to load Url

node.js - GeoJSON 在 Node.js 中与 Mongoose/Mongodb 配合使用

javascript - 正确的方式?在 NodeJS 和 HTML 中包含 JS

visual-studio-2008 - 应用程序无法正常启动 0xc00007b

node.js - 安装包时如何强制 npm 使用不同的 node-gyp 版本?