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

node.js Node.js

西门

2020-03-23

我无法安装任何需要编译的模块。它们全部失败,并出现以下错误:

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

我的环境:

  • Windows 7 Enterprise x64版本6.1.7601
  • 节点x86 0.8.16
  • npm 1.2.0
  • 节点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等。

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

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

也许您对此有一些想法?

谢谢。

第3084篇《无法在Windows 7 x64 / VS2012上安装需要编译的节点模块》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

17个回答
Itachi 2020.03.23

在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下载的原始节点模块)中,以管理员权限运行vcbuild.batvcbild.bat将生成与Windows相关的依赖关系,并将在node-master中添加文件夹名称Release

一旦运行,将需要一些时间来构建文件。

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

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

这将建立所有依赖关系。

老丝阿飞 2020.03.23

我在编译nodejs zmq时也遇到了很多问题。

对于vcbuild.exe的问题,只需将其添加到PATH中

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

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

并从提示:

npm install zmq

这是可行的:)

Mandy 2020.03.23

我通过本教程在Windows 8和Windows 10 Pro上解决了这个问题。我尝试了很多次,使用许多不同的解决方案来解决此问题,但仅对此起作用:http : //www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express -2015-on-windows-10-pro-x64 我注意到我没有像本教程一样使用nodist来控制节点版本,我使用了NVM并且运行良好,我没有使用nodist测试本教程。我使用了节点5.2.0。

2020.03.23

经过长时间的奋斗,我将节点体系结构切换为x86,它的工作原理很吸引人。

Tony凯 2020.03.23
  1. 安装Python 2.7(非3.x)
  2. 将路径添加到vcbuild.exe环境变量中包含的目录PATH
  3. 如果您需要vcbuild.exe在这里获取它 https://github.com/kin9puppy/vcbuildFixForNode
古一LEY 2020.03.23

在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
飞云西门Tony 2020.03.23

我认为解决方案是为带有.net Framework 3.5的Server 2008下载 安装Microsoft Windows SDK

仅安装Visual Studio 2008

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

谢谢

小胖Gil 2020.03.23

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

SET VisualStudioVersion=11.0
npm install zmq
npm install protobuf
Stafan 2020.03.23

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

“因为--msvs_version = 2013在构建脚本运行时未传递给node-gyp。请设置GYP_MSVS_VERSION = 2013 env变量,此后它应该可以工作。”

砰! 有效

老丝阿飞 2020.03.23

经过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命令。

西门 2020.03.23

在Windows 8上,它对我有用:

npm install -g node-gyp -msvs_version=2012

然后

npm install -g restify
猿前端前端 2020.03.23

更新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

原版的:

无需整个Visual Studio,您只需下载构建工具

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

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

npm config set msvs_version 2013 --global

在此之后,一切应该恢复正常,并且您的npm install / node-gyp rebuild将正常工作

梅蛋蛋 2020.03.23

感谢@felixrieseberg,您只需要安装Windows-build-tools npm软件包,就可以了。

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的现有安装混淆。

达蒙村村 2020.03.23

只需添加--msvs_version = 2012

node-gyp rebuild --msvs_version=2012

要么

node-gyp configure --msvs_version=2012
node-gyp build 
斯丁西门 2020.03.23

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

node-gyp rebuild --msvs_version=2012

npm install <module> --msvs_version=2012

按照@Jacob的评论

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

小哥宝儿 2020.03.23

尝试-将全局设置:

npm config set msvs_version 2012 --global
老丝阿飞 2020.03.23

尝试为Node.js安装软件包时遇到了相同的问题。经过大量的糊涂之后,我发现了这个步行槽:https : //github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup

完成这些步骤后,我可以使用“ npm install”而不会出现任何问题。

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android