npm 在CentOS 7.9 VM上安装zeromq时,为什么会出现涉及node-gyp的错误?

xurqigkl  于 2023-01-31  发布在  其他
关注(0)|答案(1)|浏览(158)

我有一个NextJS应用程序在我的Windows机器上,并已能够使用zeromq包没有任何问题。但当我试图安装相同的项目在我的CentOS 7.9虚拟机,我得到了一些错误相关的node-gyp。我试图按照一些步骤在其他线程,但没有解决我的问题。我还删除了zeromq从package.json,删除package-lock.json,并清除了我的npm缓存,以便我可以尝试全新安装zeromq:

npm install zeromq

下面是错误日志:

npm ERR! code 1
npm ERR! path /home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq
npm ERR! command failed
npm ERR! command sh -c -- (shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true node-gyp-build
npm ERR! make: Entering directory `/home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq/build'
npm ERR!   TOUCH 7722eaf02fcc073df28ffd1fa831e71544edfd42.intermediate
npm ERR!   ACTION binding_gyp_libzmq_target_build_libzmq 7722eaf02fcc073df28ffd1fa831e71544edfd42.intermediate
npm ERR! Downloading libzmq source from https://github.com/zeromq/libzmq/archive/20de92ac0a2b2b9a1869782a429df68f93c3625e.tar.gz
npm ERR! Building libzmq Release
npm ERR! cmake -S "libzmq-20de92ac0a2b2b9a1869782a429df68f93c3625e" -B ./build  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq/build/libzmq" -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_STATIC=ON -DBUILD_TESTS=OFF -DBUILD_SHARED=OFF -DWITH_DOCS=OFF -DWITH_LIBSODIUM=ON -DWITH_LIBSODIUM_STATIC=ON
npm ERR! cmake --build ./build --config Release --target install
npm ERR!   TOUCH Release/obj.target/libzmq.stamp
npm ERR!   CXX(target) Release/obj.target/zeromq/src/context.o
npm ERR! rm 7722eaf02fcc073df28ffd1fa831e71544edfd42.intermediate
npm ERR! make: Leaving directory `/home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq/build'
npm ERR! /lib64/libc.so.6: version `GLIBC_2.33' not found (required by /home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq/prebuilds/linux-x64/node.napi.glibc.node)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@16.18.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.6.8 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/fsmdevuser/.cache/node-gyp/16.18.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/fsmdevuser/.cache/node-gyp/16.18.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/fsmdevuser/.cache/node-gyp/16.18.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! /bin/sh: cmake: command not found
npm ERR! /bin/sh: cmake: command not found
npm ERR! g++: error: unrecognized command line option ‘-std=gnu++14’
npm ERR! g++: error: unrecognized command line option ‘-std=c++17’
npm ERR! make: *** [Release/obj.target/zeromq/src/context.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Linux 3.10.0-1160.76.1.el7.x86_64
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq
npm ERR! gyp ERR! node -v v16.18.1
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fsmdevuser/.npm/_logs/2023-01-30T08_31_00_652Z-debug-0.log

如果有用的话,我的节点版本是16.18.1,npm是8.19.2,node-gyp --version返回0.10.6
编辑:我尝试sudo yum install cmake看看它是否修复了什么,现在我得到了一个更短的错误消息

npm ERR! code 126
npm ERR! path /home/fsmdevuser/fsm-poc/web-app/node_modules/zeromq
npm ERR! command failed
npm ERR! command sh -c -- (shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true node-gyp-build
npm ERR! sh: /home/fsmdevuser/fsm-poc/web-app/node_modules/.bin/cross-env: Permission denied

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fsmdevuser/.npm/_logs/2023-01-30T08_50_27_526Z-debug-0.log
wfveoks0

wfveoks01#

昨天我在Ubuntu 22上的另一个软件包heapdump遇到了同样的问题。解决办法是全局安装node-gyp

sudo npm install -g node-gyp

相关问题