我发现很多类似这个问题的答案,但是它们都不能解决我的问题。这是我安装的版本:
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.
对此有什么想法吗?