npm install sqlite3 --save 报错

[root@MiWiFi-R3P-srv hao]# npm install sqlite3
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
npm ERR! code 1
npm ERR! path /www/wwwroot/hao/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute ‘/www/server/nodejs/v16.18.1/bin/node /www/server/nodejs/v16.18.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/www/wwwroot/hao/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/www/wwwroot/hao/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6’ (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | linux | arm64
npm ERR! node-pre-gyp info check checked for “/www/wwwroot/hao/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64/node_sqlite3.node” (not found)
npm ERR! node-pre-gyp http GET https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.2/napi-v6-linux-glibc-arm64.tar.gz
npm ERR! node-pre-gyp ERR! install request to https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.2/napi-v6-linux-glibc-arm64.tar.gz failed, reason: connect ETIMEDOUT 20.205.243.166:443
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v93 ABI, glibc) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error request to https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.2/napi-v6-linux-glibc-arm64.tar.gz failed, reason: connect ETIMEDOUT 20.205.243.166:443
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 | arm64
npm ERR! gyp info ok
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 | arm64
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if “python3” can be used
npm ERR! gyp ERR! find Python - “python3” is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if “python” can be used
npm ERR! gyp ERR! find Python - executable path is “/usr/bin/python”
npm ERR! gyp ERR! find Python - version is “2.7.5”
npm ERR! gyp ERR! find Python - version is 2.7.5 - should be >=3.6.0
npm ERR! gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python=“/path/to/pythonexecutable”
npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python npm config set python “/path/to/pythonexecutable”
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack at PythonFinder.fail (/www/server/nodejs/v16.18.1/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack at PythonFinder.runChecks (/www/server/nodejs/v16.18.1/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack at PythonFinder. (/www/server/nodejs/v16.18.1/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:266:16)
npm ERR! gyp ERR! stack at PythonFinder.execFileCallback (/www/server/nodejs/v16.18.1/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:297:7)
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:394:7)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
npm ERR! gyp ERR! stack at Socket. (node:internal/child_process:458:11)
npm ERR! gyp ERR! stack at Socket.emit (node:events:513:28)
npm ERR! gyp ERR! stack at Pipe. (node:net:301:12)
npm ERR! gyp ERR! System Linux 5.8.0-arm-64
npm ERR! gyp ERR! command “/www/server/nodejs/v16.18.1/bin/node” “/www/server/nodejs/v16.18.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “configure” “–fallback-to-build” “–module=/www/wwwroot/hao/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64/node_sqlite3.node” “–module_name=node_sqlite3” “–module_path=/www/wwwroot/hao/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64” “–napi_version=8” “–node_abi_napi=napi” “–napi_build_version=6” “–node_napi_label=napi-v6”
npm ERR! gyp ERR! cwd /www/wwwroot/hao/node_modules/sqlite3
npm ERR! gyp ERR! node -v v16.18.1
npm ERR! gyp ERR! node-gyp -v v9.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute ‘/www/server/nodejs/v16.18.1/bin/node /www/server/nodejs/v16.18.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/www/wwwroot/hao/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/www/wwwroot/hao/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6’ (1)
npm ERR! node-pre-gyp ERR! stack at ChildProcess. (/www/wwwroot/hao/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
npm ERR! node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm ERR! node-pre-gyp ERR! System Linux 5.8.0-arm-64
npm ERR! node-pre-gyp ERR! command “/www/server/nodejs/v16.18.1/bin/node” “/www/wwwroot/hao/node_modules/.bin/node-pre-gyp” “install” “–fallback-to-build”
npm ERR! node-pre-gyp ERR! cwd /www/wwwroot/hao/node_modules/sqlite3
npm ERR! node-pre-gyp ERR! node -v v16.18.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR! /www/server/nodejs/v16.18.1/cache/_logs/2022-11-25T17_53_28_662Z-debug-0.log

npm i node-pre-gyp -g
解决!
您是否成功安装了其他npm软件包? 否则尝试用npm install -g npm更新您的npm

这似乎是一个权限错误。 使用sudo运行更新命令:sudo npm install -g npm
解决!
最后通过一通百度,下面哪条命令解决的问题已经不知道了.反正是解决了

npm run clean && webpack --config webpack.config.js --progress --color

npm run build

react-app-rewired build

npm cache clean

npm cache clean sqlite3

sudo npm install sqlite3

最后发现用不了,提示缺libstdc++.so.6(CXXABI_1.3.8)(64bit)

接着研究

出现这个错误是因为CentOS7当前版本默认的GCC的版本太老,里面的动态链接库没有GLIBCXX_1.3.8。

执行以下命令检查动态库:

$ strings /usr/lib64/libstdc++.so.6 | grep GLIBC
输出结果如下:

可以看到确实没有GLIBCXX_1.3.8

执行以下命令查看当前gcc版本:

$ gcc -v
输出gcc版本:

gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
执行命令查看libstdc++.so.6的位置:

$ find / -name libstdc++.so.6*
列出与libstdc++.so.6相关的文件:

/usr/lib64/libstdc++.so.6.0.19
/usr/lib64/libstdc++.so.6
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/data/result/SegParser/libstdc++.so.6
/data/download_record/SegParser/libstdc++.so.6
/data/segdsegy/SegParser/libstdc++.so.6
可以看到当前动态连接库版本是libstdc++.so.6.0.19。

进入/usr/lib64目录查看软链接情况:

$ ls -l libstdc++.so*
显示结果:

lrwxrwxrwx 1 root root 19 Mar 18 11:39 libstdc++.so.6 -> libstdc++.so.6.0.19
-rwxr-xr-x 1 root root 991616 Oct 30 14:39 libstdc++.so.6.0.19
软链接就链接到了libstdc++.so.6.0.19这个版本上。

鉴于系统内不存在更高版本的libstdc++.so.6的库,遂计划升级GCC版本。

升级GCC版本
安装开发必备环境:

$ yum groupinstall “Development Tools”
$ yum install glibc-static libstdc+±static
GCC源码地址为http://ftp.gnu.org/gnu/gcc,里面有GCC的各个版本,请根据各自的需要下载。这里索性选择了当前最新版本gcc-8.3.0。

找到或创建并进入到一个临时目录,执行命令:

$ wget http://ftp.gnu.org/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.gz
下载完成之后,解压文件:

$ tar -zxvf gcc-8.3.0.tar.gz
解压完成,进入文件目录:

$ cd gcc-8.3.0
利用源码包里自带的工具下载所需要的依赖项:

$ ./contrib/download_prerequisites
创建编译输出目录:

mkdir build
进入build目录:

$ cd build
生成Makefile:

$ …/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
编译:

$ make
make的过程如果遇到如下错误:

collect2: ld terminated with signal 9 [Killed]
有可能是主机内存过低造成的,可通过设置swap文件来解决:

$ cd ~
$ mkdir swap
$ cd swap
$ dd if=/dev/zero of=swapfile count=4096 bs=1024k
$ chmod 600 swapfile
$ mkswap swapfile
$ swapon swapfile
通过命令:

$ swapon -s //查看swap文件的状态
$ free -m //查看内存当前用量
查看swap分区文件的挂载情况。

编译完成之后,安装:

$ make install
完成安装之后,检查是否安装成功:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: …/configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
Thread model: posix
gcc version 8.3.0 (GCC)
gcc版本已变成最新版,查看动态库是否已正常:

$ strings /usr/lib64/libstdc++.so.6 | grep GLIBC
然而发现并没有,查找编译gcc时生成的最新动态库:

$ find / -name “libstdc++.so*”
执行结果如下:

/usr/local/lib64/libstdc++.so.6.0.25
/usr/local/lib64/libstdc++.so
/usr/local/lib64/libstdc++.so.6.0.25-gdb.py
/usr/local/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/lib64/libstdc++.so.6
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libstdc++.so
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/opt/gcc-8.3.0/build/x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so.6.0.25
/opt/gcc-8.3.0/build/x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so
/opt/gcc-8.3.0/build/x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so.6
/opt/gcc-8.3.0/build/stage1-x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so.6.0.25
/opt/gcc-8.3.0/build/stage1-x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so
/opt/gcc-8.3.0/build/stage1-x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so.6
/opt/gcc-8.3.0/build/prev-x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so.6.0.25
/opt/gcc-8.3.0/build/prev-x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so
/opt/gcc-8.3.0/build/prev-x86_64-pc-linux-gnu/libstdc+±v3/src/.libs/libstdc++.so.6
/data/result/SegParser/libstdc++.so.6
/data/download_record/SegParser/libstdc++.so.6
/data/segdsegy/SegParser/libstdc++.so.6
可以看到在路径/usr/local/lib64/libstdc++.so.6.0.25下有一个新的高版本的库,于是将此库复制到/usr/lib64/路径下并重新建立软连接:

$ cp /usr/local/lib64/libstdc++.so.6.0.25 /usr/lib64/
$ rm libstdc++.so.6
$ ln -s libstdc++.so.6.0.25 libstdc++.so.6
完成之后通过命令

strings /usr/lib64/libstdc++.so.6 | grep GLIBC
可以看到GLIBCXX_1.3.8已经存在。

问题解决。

作者:什么都懂一点的小白
链接:https://www.jianshu.com/p/cedbdf0b6bca
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

猜你喜欢

转载自blog.csdn.net/Sncdma/article/details/128047244