我正在尝试从nodejs向kafka代理发布消息。当我尝试在nodejs窗口中安装kafka-node模块时。我得到了与python相关的异常。
C:\Program Files\nodejs>npm install kafka-node
-
> snappy@4.1.2 install C:\Program Files\nodejs\node_modules\kafka-node\node_modules\snappy
> node-gyp rebuild
C:\Program Files\nodejs\node_modules\kafka-node\node_modules\snappy>if not defined npm_config_node_g
yp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin
\node-gyp.js" rebuild ) else (node rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Python executable "python" is v3.4.0, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack at failPythonVersion (C:\Program Files\nodejs\node_modules\npm\node_modules\node-
gyp\lib\configure.js:121:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.j
s:110:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:204:7)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at maybeClose (internal/child_process.js:821:16)
gyp ERR! stack at Socket.<anonymous> (internal/child_process.js:319:11)
gyp ERR! stack at emitOne (events.js:77:13)
gyp ERR! stack at Socket.emit (events.js:169:7)
gyp ERR! stack at Pipe._onclose (net.js:469:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm
\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\kafka-node\node_modules\snappy
gyp ERR! node -v v4.3.2
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\b
in\\npm-cli.js" "install" "kafka-node"
npm ERR! node v4.3.2
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! snappy@4.1.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the snappy@4.1.2 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the snappy package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls snappy
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Program Files\nodejs\npm-debug.log
kafka-node和python之间是否有任何关系。我已经设置了python 3.4并再次尝试安装kafka-node模块,它说gyp不支持python3.4版本。 (以下是错误消息)
所以我安装了python 2.6并再次尝试再次安装kafka-node,它给出了以下错误
C:\Program Files\nodejs\node_modules\kafka-node\node_modules\snappy>if not defined npm_config_node_g
yp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin
\node-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m"
switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) ins
tall 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. [C:\Program Files\nodejs\node_modul
es\kafka-node\node_modules\snappy\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit c
ode: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\nod
e-gyp\lib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm
\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\kafka-node\node_modules\snappy
gyp ERR! node -v v4.3.2
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\b
in\\npm-cli.js" "install" "kafka-node"
npm ERR! node v4.3.2
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! snappy@4.1.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the snappy@4.1.2 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the snappy package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls snappy
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Program Files\nodejs\npm-debug.log
任何帮助表示赞赏。谢谢
答案 0 :(得分:0)
您第二次尝试时恢复的错误是:
MSBUILD:错误MSB3428:无法加载Visual C ++组件“VCBuild.exe”。为了解决这个问题,1)ins 高大的.NET Framework 2.0 SDK,2)安装Microsoft Visual Studio 2005或3)添加位置 系统路径的组件,如果它安装在别处。
您是否安装了安装了C ++编译器的Visual Studio?如果没有,你应该安装它。
其他有用的答案可以在这篇文章中找到: Error in installing node.js module using npm
答案 1 :(得分:0)
node-gyp用于构建snappy依赖项。压缩库。如果你不在kafka消息中使用压缩,你可以放心地忽略它。在版本0.3.3中,此依赖项是可选的。
如果您不使用snappy,只需使用--no-optional
标志安装模块:
npm install kafka-node --no-optional