簡體   English   中英

無法在Windows 7 x64 / VS2012上安裝需要編譯的節點模塊

[英]Cannot install node modules that require compilation on Windows 7 x64/VS2012

我無法安裝任何需要編譯的模塊。 所有這些都失敗了以下錯誤:

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

也許你會有一些想法嗎?

謝謝。

試試 - 將全局設置:

npm config set msvs_version 2012 --global

要在沒有VS2010安裝且僅2012年的情況下執行此操作,請設置msvs_version標志:

node-gyp rebuild --msvs_version=2012

npm install <module> --msvs_version=2012

根據@Jacob評論

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

更新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將會起作用

只需添加--msvs_version = 2012

node-gyp rebuild --msvs_version=2012

要么

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

嘗試為Node.js安裝軟件包時遇到了同樣的問題。 經過一些廣泛的googeling后,我發現了這個漫步: https//github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup

當我按照這些步驟操作時,我可以使用“npm install”而不會出現任何問題。

感謝@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的現有安裝。

在Windows 8上,它對我有用:

npm install -g node-gyp -msvs_version=2012

然后

npm install -g restify

在挖掘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命令。

我有同樣的isuee並完成了上面的所有魔法,唯一為我做了魔術的是來自https://github.com/atom/atom/issues/2435

“因為--msvs_version = 2013在構建腳本運行時沒有傳遞給node-gyp。設置GYP_MSVS_VERSION = 2013 env變量,它應該在之后工作。”

砰! 有效

在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

對於Windows 8 64位,安裝zmq和protobuf,以下適用於我:安裝Visual Studio 2012在命令行上:

SET VisualStudioVersion=11.0
npm install zmq
npm install protobuf

我認為解決方案是使用.net framework 3.5下載安裝Microsoft Windows sdk for server 2008

或者只是安裝Visual Studio 2008

問題是windows build node-gyp執行vcbuid.exe文件,由於某種原因它無法找到它。

謝謝

  1. 安裝Python 2.7(不是3.x)
  2. 將路徑添加到環境變量PATH上包含vcbuild.exe的目錄
  3. 如果你需要vcbuild.exe ,請點擊這里https://github.com/kin9puppy/vcbuildFixForNode

經過長時間的奮斗,我已經將我的節點架構轉換為x86,它就像一個魅力。

我編譯nodejs zmq也有很多問題。

有關vcbuild.exe的問題,只需將其添加到PATH

對於其他問題,我可以使用Windows 7.1 SDK Command Prompt編譯

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

並從提示:

npm install zmq

那是有效的:)

在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"

這將構建所有依賴項。

我在本教程的Windows 8和Windows 10專業版上解決了這個問題。 我嘗試了很多次用許多不同的解決方案解決這個問題,但只對我有用: 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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM