问题描述
Node17 npm9.6.2 CentOS7 GCC4.8.5
安装 better-sqlite3 时候,报错:
npm ERR! g++: error: unrecognized command line option ‘-std=gnu++17’
npm ERR! g++: error: unrecognized command line option ‘-std=c++17’
具体信息:
npm ERR! code 1 npm ERR! path /usr/local/lib/node_modules/better-sqlite3 npm ERR! command failed npm ERR! command sh -c prebuild-install || node-gyp rebuild --release npm ERR! make: Entering directory `/usr/local/lib/node_modules/better-sqlite3/build' npm ERR! TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate npm ERR! ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate npm ERR! TOUCH Release/obj.target/deps/locate_sqlite3.stamp npm ERR! CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o npm ERR! rm -f Release/obj.target/deps/sqlite3.a Release/obj.target/deps/sqlite3.a.ar-file-list; mkdir -p `dirname Release/obj.target/deps/sqlite3.a` npm ERR! ar crs Release/obj.target/deps/sqlite3.a @Release/obj.target/deps/sqlite3.a.ar-file-list npm ERR! COPY Release/sqlite3.a npm ERR! CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o npm ERR! rm ba23eeee118cd63e16015df367567cb043fed872.intermediate npm ERR! make: Leaving directory `/usr/local/lib/node_modules/better-sqlite3/build' npm ERR! prebuild-install warn install No prebuilt binaries found (target=17.0.1 runtime=node arch=x64 libc= platform=linux) npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using [email protected] npm ERR! gyp info using [email protected] | 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/local/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 '/usr/local/lib/node_modules/better-sqlite3/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/root/.cache/node-gyp/17.0.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=/root/.cache/node-gyp/17.0.1', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/17.0.1/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/better-sqlite3', 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! g++: error: unrecognized command line option ‘-std=gnu++17’ npm ERR! g++: error: unrecognized command line option ‘-std=c++17’ npm ERR! make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.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/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) npm ERR! gyp ERR! System Linux 5.11.0-1.el7.elrepo.x86_64 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/better-sqlite3 npm ERR! gyp ERR! node -v v17.0.1 npm ERR! gyp ERR! node-gyp -v v9.3.1 npm ERR! gyp ERR! not ok
问题解决
在服务器上安装如下
yum install centos-release-scl yum install devtoolset-7-gcc* scl enable devtoolset-7 bash gcc --version
文章评论