首页 文章

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

提问于
浏览
186

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

MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". ...

我的环境:

  • Windows 7 Enterprise x64,版本6.1.7601

  • node 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

没有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

我试图用相同的变量调用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

也许你会有一些想法吗?

谢谢 .

17 回答

  • 0
  • 2

    我编译nodejs zmq也有很多问题 .

    有关vcbuild.exe的问题,只需将其添加到PATH

    对于其他问题,我可以使用 Windows 7.1 SDK Command Prompt 编译

    (菜单程序 - > Microsoft Windows SDK v7.1 - > Windows 7.1 SDK命令提示符)

    并从提示:

    npm install zmq

    那是有效的:)

  • 0

    经过长时间的努力,我已经将我的节点架构转换为x86,它就像一个魅力 .

  • 0

    试试 - 将全局设置:

    npm config set msvs_version 2012 --global
    
  • 41

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

    node-gyp rebuild --msvs_version=2012

    npm install <module> --msvs_version=2012

    按@Jacob评论

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

  • 140

    更新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更新了自述文件以包含HOW-TO for windows

    原版的:

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

    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将会起作用

  • 1

    只需添加--msvs_version = 2012

    node-gyp rebuild --msvs_version=2012
    

    要么

    node-gyp configure --msvs_version=2012
    node-gyp build
    
  • 59

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

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

  • 21

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

    npm install --global --production windows-build-tools
    

    您不需要安装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的现有安装 .

  • 4

    在Windows 8上,它对我有用:

    npm install -g node-gyp -msvs_version=2012
    

    然后

    npm install -g restify
    
  • 0

    在挖掘DAYS之后,IRC的某个人建议我尝试使用

    Windows 7.1 SDK Command Prompt
    

    快捷方式(链接到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
    

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

  • 142

    我有同样的isuee并完成了上面的所有魔法,唯一为我做了魔术的是来自https://github.com/atom/atom/issues/2435

    “因为--msvs_version = 2013在构建脚本运行时没有传递给node-gyp . 设置GYP_MSVS_VERSION = 2013 env变量,它应该在之后工作 . ”

    砰!有效

  • 13

    在Windows上这有助于我:(学分)https://github.com/TooTallNate/node-gyp/wiki/Updating-npm%27s-bundled-node-gyp我尝试了MINGW32,但没有成功 .

    cmd.exe

    $ cd "C:\Program Files\nodejs\node_modules\npm"
    $ npm install -g node-gyp@latest
    
  • 1

    对于Windows 8 64位,安装zmq和protobuf,以下适用于我:安装Visual Studio 2012在命令行上:

    SET VisualStudioVersion=11.0
    npm install zmq
    npm install protobuf
    
  • 11

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

    just install Visual studio 2008 .

    问题是windows build node-gyp执行vcbuid.exe文件,由于某种原因它无法找到它 .

    谢谢

  • 5

    在cmd中设置Visual Studio路径,具体取决于您的版本

    Visual Studio 2010 (VS10): SET VS90COMNTOOLS=%VS100COMNTOOLS%
    
    Visual Studio 2012 (VS11): SET VS90COMNTOOLS=%VS110COMNTOOLS%
    
    Visual Studio 2013 (VS12): SET VS90COMNTOOLS=%VS120COMNTOOLS%
    

    在node-master(从git下载的原始节点模块)中,使用admin权限运行 vcbuild.bat . vcbild.bat将生成与Windows相关的依赖项,并将在node-master中添加文件夹名称Release

    一旦运行,构建文件需要一些时间 .

    然后在具有.gyp文件的目录中使用命令

    node-gyp rebuild --msvs_version=2012 --nodedir="Dive Name:\path to node-master\node-master"
    

    这将构建所有依赖项 .

  • 3

    我在本教程的Windows 8和Windows 10专业版上解决了这个问题 . 我尝试了很多次用许多不同的解决方案解决这个问题,但只对我有用:http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64我注意到我没有用nodist测试本教程 . 我使用了节点5.2.0 .

相关问题