无法在Windows 7 x64/VS2012上安装需要编译的节点模块

Ale*_*hov 191 node.js node-gyp visual-studio-2012

我无法安装任何需要编译的模块.所有这些都失败了,出现以下错误:

MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". ...
Run Code Online (Sandbox Code Playgroud)

我的环境:

  • Windows 7 Enterprise x64,版本6.1.7601
  • 节点x86 0.8.16
  • npm 1.2.0
  • node-gyp 0.8.2
  • Visual Studio 2012和众多软件包

相关环境变量:

Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShel l\v1.0;C:\Program Files\TortoiseGit\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\tools;c:\tools\node
Run Code Online (Sandbox Code Playgroud)

没有INCLUDE,LIB,LIBPATH等

我对该问题进行了简短的调查,并通过以下设置确定手动编译(直接调用VCBuild.exe和msbuild.exe)成功进行手动克隆的git://github.com/einaros/ws.git:

SET Configuration=Release
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcpackages
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
SET PATH=%SystemRoot%\system32;%PATH%

SET INCLUDE=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\include
SET INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%

SET LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib
SET LIB=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\lib;%LIB%

SET MSBUILD="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"

VCBuild.exe C:\Tools\node\ws\build\bufferutil.vcproj "Release|Win32" /useenv
VCBuild.exe C:\Tools\node\ws\build\validation.vcproj "Release|Win32" /useenv
%MSBUILD% build/binding.sln /verbosity:diagnostic /nologo /p:Configuration=Release;Platform=Win32
Run Code Online (Sandbox Code Playgroud)

我试图用相同的变量调用node-gyp,但它失败了:

C:\!> git clone https://github.com/einaros/ws.git
C:\!> cd ws
C:\!\ws>node-gyp configure
...
C:\!\ws>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@0.8.2
gyp info using node@0.8.16 | win32 | ia32
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=Win32' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\build\binding.sln]
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\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
gyp ERR! stack     at ChildProcess.onExit (c:\Tools\node\node_modules\node-gyp\lib\build.js:255:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "c:\\Tools\\node\\\\node.exe" "c:\\Tools\\node\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\!\ws
gyp ERR! node -v v0.8.16
gyp ERR! node-gyp -v v0.8.2
gyp ERR! not ok
Run Code Online (Sandbox Code Playgroud)

也许你会有一些想法吗?

谢谢.

srf*_*rnk 147

试试 - 将全局设置:

npm config set msvs_version 2012 --global
Run Code Online (Sandbox Code Playgroud)

  • 很好,我在运行一组脚本深度调用npm的脚本时收到错误.我不想修改脚本,所以这对我来说是最好的选择 (2认同)
  • 这应该是推荐的答案,就像Windows 10上的魅力一样 (2认同)
  • 不起作用。`错误 MSB4019:未找到导入的项目“C:\Microsoft.Cpp.Default.props”。` (2认同)

Ale*_*lex 143

要在没有VS2010安装且仅2012年的情况下执行此操作,请设置msvs_version标志:

node-gyp rebuild --msvs_version=2012

npm install <module> --msvs_version=2012

根据@Jacob评论

npm install --msvs_version=2013 如果您有2013版本

  • 也适用于`-msvs_version = 2013`,仅供参考. (7认同)
  • 虽然我相信第二个命令在其参数上也应该有两个连字符 - 我为它添加了两个连字符并且它有效.这让我超过了我的npm安装错误 - 谢谢! (3认同)

cat*_*int 60

更新v3:https: //www.npmjs.com/package/windows-build-tools

npm install --global windows-build-tools

下载并安装Microsoft免费提供的Visual C++ Build Tools 2015.编译流行的本机模块需要这些工具.它还将安装Python 2.7,适当地配置你的机器和npm.

更新v2:

node-gyp更新了他们的自述文件以包含Windows的HOW-TO

原版的:

无需整个视觉工作室,您只需下载构建工具即可

Microsoft Build Tools 2013:http://www.microsoft.com/en-us/download/details.aspx?id = 40760

运行cmd以设置全局标志以使用2013版本:

npm config set msvs_version 2013 --global

在这之后一切都应该恢复正常,你的npm install/node-gyp rebuild将会起作用

  • 我安装了VS2015并运行了这个命令`npm config set msvs_version 2015 --global`也可以 (2认同)

msu*_*has 41

只需添加--msvs_version = 2012

node-gyp rebuild --msvs_version=2012
Run Code Online (Sandbox Code Playgroud)

要么

node-gyp configure --msvs_version=2012
node-gyp build 
Run Code Online (Sandbox Code Playgroud)

  • 你让我今天一整天都感觉很好 (5认同)

小智 21

尝试为Node.js安装软件包时遇到了同样的问题.经过一些广泛的googeling后,我发现了这个漫步:https://github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup

当我按照这些步骤操作时,我可以使用"npm install"而不会出现任何问题.


Ram*_*lat 13

感谢@felixrieseberg,你只需要安装windows-build-tools npm包就可以了.

npm install --global --production windows-build-tools
Run Code Online (Sandbox Code Playgroud)

您不需要安装Visual Studio.

您无需安装Microsoft Build Tools.

来自回购:

安装完成后,npm将自动执行此模块,该模块下载并安装Microsoft免费提供的Visual C++ Build Tools 2015.编译流行的本机模块需要这些工具.它还将安装Python 2.7,适当地配置你的机器和npm.

Windows Vista/7需要.NET Framework 4.5.1(当前未由此软件包自动安装)

这两个安装都是无冲突的,这意味着它们不会混淆Visual Studio,C++ Build Tools或Python的现有安装.


amg*_*han 11

在Windows 8上,它对我有用:

npm install -g node-gyp -msvs_version=2012
Run Code Online (Sandbox Code Playgroud)

然后

npm install -g restify
Run Code Online (Sandbox Code Playgroud)


rai*_*bba 5

在挖掘DAYS之后,IRC上有人建议我尝试使用

Windows 7.1 SDK Command Prompt
Run Code Online (Sandbox Code Playgroud)

快捷方式(链接到C:\ Windows\System32\cmd.exe/E:ON/V:ON/T:0E/K"C:\ Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" ).我认为你必须拥有旧版的7.1 SDK(即使在Windows 8.1上),因为较新的版本使用msbuild.exe而不是vcbuild.exe,这就是node-gyp想要的,即使它在这一点上是节点的两倍:/

进入该提示后,我必须运行以下命令来获取x86上下文,因为编译器抛出了关于体系结构的错误:

setenv.cmd /Release /x86
Run Code Online (Sandbox Code Playgroud)

然后我能够成功运行试图使用node-gyp重新编译的npm命令.


Hub*_*lla 1

我认为解决方案是下载 安装 Microsoft windows sdk for server 2008 with .net Framework 3.5

或者只安装 Visual Studio 2008

问题是 Windows 构建的 node-gyp 执行 vcbuid.exe 文件,并且由于某种原因找不到它。

谢谢

  • 找不到 VCBuild 的原因是它在 2010 年被 MSBuild 取代,根据 http://www.codeproject.com/Articles/562386/Lessons-learned-migration-to-Visual-Studio-2012-an (2认同)