无法安装npm包(kafka streams)

uyto3xhc  于 2021-06-04  发布在  Kafka
关注(0)|答案(2)|浏览(819)

我正在尝试使用npm包kafka streams,但出现以下错误:

PS D:\Projects\POCs\kstreams-poc> npm install kafka-streams

> node-rdkafka@2.7.1 install D:\Projects\POCs\kstreams-poc\node_modules\node-rdkafka
> node-gyp rebuild

D:\Projects\POCs\kstreams-poc\node_modules\node-rdkafka>if not defined npm_config_node_gyp (node "C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS**************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS**************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:344:14)
gyp ERR! stack     at C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:365:16
gyp ERR! stack     at C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Users\virtual\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:302:5)
gyp ERR! stack     at ChildProcess.emit (events.js:203:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\virtual\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Projects\POCs\kstreams-poc\node_modules\node-rdkafka
gyp ERR! node -v v12.7.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
npm WARN kstreams-poc@1.0.0 No description
npm WARN kstreams-poc@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-rdkafka@2.7.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-rdkafka@2.7.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

尝试了以下几件事:
1已安装的windows生成工具
2已安装python(2.7.16)
三。更新节点(v12.7.0)
4已安装visual c生成工具。
根据matt的建议,我也安装了visualc
构建工具。现在我得到以下错误:

gyp info spawn args ]
gyp: binding.gyp not found (cwd: D:\Projects\POCs\kstreams-poc) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\virtual\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:344:16)
gyp ERR! stack     at ChildProcess.emit (events.js:203:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\virtual\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Projects\POCs\kstreams-poc
gyp ERR! node -v v12.7.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok

更新:1
最后,我成功地构建了节点gyp:

PS D:\Projects\POCs\test-kstream> node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.3
gyp info using node@12.7.0 | win32 | x64
gyp info find Python using Python version 2.7.16 found at "C:\Python27\python.exe"
gyp info find VS using VS2017 (15.9.28307.770) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python27\python.exe
gyp info spawn args [## Heading ##
gyp info spawn args   'C:\\Users\\virtual\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\Projects\\POCs\\test-kstream\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\virtual\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\virtual\\AppData\\Local\\node-gyp\\Cache\\12.7.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\virtual\\AppData\\Local\\node-gyp\\Cache\\12.7.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\virtual\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\virtual\\AppData\\Local\\node-gyp\\Cache\\12.7.0\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=D:\\Projects\\POCs\\test-kstream',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'D:\\Projects\\POCs\\test-kstream\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Warning: Missing input files:
D:\Projects\POCs\test-kstream\build\..\build\Release\binding.node
gyp info ok

但在尝试安装Kafka流时仍然出现以下错误

d:\projects\pocs\test-kstream\node_modules\node-rdkafka\src\workers.cc(909): warning C4996: 'Nan::Callback::Call': was declared deprecated [
D:\Projects\POCs\test-kstream\node_modules\node-rdkafka\build\node-librdkafka.vcxproj]
  d:\projects\pocs\test-kstream\node_modules\nan\nan.h(1740): note: see declaration of 'Nan::Callback::Call'
d:\projects\pocs\test-kstream\node_modules\node-rdkafka\src\workers.h(42): warning C4996: 'Nan::Callback::Call': was declared deprecated (co
mpiling source file ..\src\admin.cc) [D:\Projects\POCs\test-kstream\node_modules\node-rdkafka\build\node-librdkafka.vcxproj]
  d:\projects\pocs\test-kstream\node_modules\nan\nan.h(1740): note: see declaration of 'Nan::Callback::Call' (compiling source file ..\src\a
  dmin.cc)
d:\projects\pocs\test-kstream\node_modules\node-rdkafka\src\admin.cc(93): warning C4996: 'v8::Object::Set': was declared deprecated [D:\Proj
ects\POCs\test-kstream\node_modules\node-rdkafka\build\node-librdkafka.vcxproj]
  c:\users\virtual\.node-gyp\12.7.0\include\node\v8.h(3365): note: see declaration of 'v8::Object::Set'
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:266:23)
gyp ERR! stack     at ChildProcess.emit (events.js:203:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.17134
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 D:\Projects\POCs\test-kstream\node_modules\node-rdkafka
gyp ERR! node -v v12.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Kafka似乎试图使用node-gyp版本(v3.8.0),但我没有

PS D:\Projects\POCs\test-kstream> node-gyp --version
v5.0.3

有什么方法可以让kafka流使用node gyp版本(v5.0.3)吗
更新:2
做了一些改变现在当我跑步的时候 npm i kafka-streams 它现在正在尝试获取节点gypv5.0.3。仍然失败:

gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\aftab.ahmed\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Projects\POCs\node_modules\node-rdkafka
gyp ERR! node -v v12.7.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'D:\Projects\POCs\package.json'
npm WARN POCs No description
npm WARN POCs No repository field.
npm WARN POCs No README data
npm WARN POCs No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-rdkafka@2.7.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-rdkafka@2.7.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
lf5gs5x2

lf5gs5x21#

看起来它正在寻找一个visualstudio版本来编译c++。 Error: Could not find any Visual Studio installation to use 它建议你去这里:https://github.com/nodejs/node-gyp#on-Windows
这是您缺少的步骤:
安装visual c生成环境:visual studio生成工具(使用“visual c生成工具”工作负载)或visual studio 2017社区(使用“使用c++进行桌面开发”工作负载)

kjthegm6

kjthegm62#

kafka streams包依赖于 Package 本机库的节点rdkafka librdkafka . 由于所有这些依赖关系,它似乎使用 kafka-streams 有点棘手。我在多台windows机器和一台linux机器上都试过了。
在花了几天的时间之后,不知何故,我用下面的步骤安装了它。
卸载node.js(确保删除缓存c:\users\aftab.ahmed\appdata\roaming\npm cache)
安装最新的node.js(v10.16.0)。这也会安装npm版本6.10.0。
使用npm install-g安装节点gypnode-gyp@5.0.3.
安装vc++/visual studio 2010生成工具。
将12.0版vc++构建工具的路径添加到path环境变量中。
安装Python2.7.16(3.x或更高版本将不起作用)。
将python2.7的路径添加到path环境变量中。
下载win32\u openssl\u 1.0.2p.exe并使用所有默认值进行安装。
完成以上步骤后,我们现在可以安装 kafka-streams ```
npm i kafka-streams

参考文献:
https://github.com/blizzard/node-rdkafka/issues/487

相关问题