1

当我在 Termux 中安装 sqlite3 时,在> node-pre-gyp install --fallback-to-build出现关于缺少预构建二进制文件的警告之后,并且在出现我不理解的错误之后:

$ npm install sqlite3@5.0.2
npm WARN deprecated node-pre-gyp@0.11.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future 
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap. 

> sqlite3@5.0.2 install /storage/emulated/0/Bots/Test/node_modules/sqlite3 
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-android-arm.tar.gz
node-pre-gyp WARN Pre-built binaries not found for sqlite3@5.0.2 and node@14.15.4 (node-v83 ABI, unknown) (falling back to source compile with node-gyp)
make: Entering directory '/storage/emulated/0/Bots/Test/node_modules/sqlite3/build' CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
AR(target) Release/obj.target/../node-addon-api/nothing.a 
COPY Release/nothing.a 
ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c 
TOUCH Release/obj.target/deps/action_before_build.stamp 
CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3340000/sqlite3.o Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:744:17: warning: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Wstring-concatenation]
"THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), ^ , Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:56:27: note: expanded from macro 'CTIMEOPT_VAL' #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) ^
Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:55:28: note: expanded from macro 'CTIMEOPT_VAL_' #define CTIMEOPT_VAL_(opt) #opt ^ :5:1: note: expanded from here "1"
^ Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c:744:3: note: place parentheses around the string literal to silence warning "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), ^ 1 warning generated. AR(target) Release/obj.target/deps/sqlite3.a 
COPY Release/sqlite3.a CXX(target) Release/obj.target/node_sqlite3/src/backup.o
../src/backup.cc:179:9: warning: unused variable 'status' [-Wunused-variable] int status = napi_create_async_work( 
^ ../src/backup.cc:252:5: warning: unused variable 'status' [-Wunused-variable] BACKUP_BEGIN(Step); 
^ ../src/macros.h:182:9: note: expanded from macro 'BACKUP_BEGIN' int status = napi_create_async_work( \ 
^
../src/backup.cc:319:5: warning: unused variable 'status' [-Wunused-variable] BACKUP_BEGIN(Finish);
^ ../src/macros.h:182:9: note: expanded from macro 'BACKUP_BEGIN'
int status = napi_create_async_work(
^ 3 warnings generated. CXX(target) Release/obj.target/node_sqlite3/src/database.o ../src/database.cc:153:9: warning: unused variable 'status' [-Wunused-variable]
int status = napi_create_async_work( 
^ ../src/database.cc:247:9: warning: unused variable 'status' [-Wunused-variable] int status = napi_create_async_work( ^ ../src/database.cc:560:9: warning: unused variable 'status' [-Wunused-variable]
int status = napi_create_async_work( 
^
../src/database.cc:669:9: warning: unused variable 'status' [-Wunused-variable] int status = napi_create_async_work( 
^ 4 warnings generated. CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o CXX(target) Release/obj.target/node_sqlite3/src/statement.o ../src/statement.cc:122:9: warning: unused variable 'status' [-Wunused-variable] int status = napi_create_async_work( 
^ ../src/statement.cc:344:5: warning: unused variable 'status' [-Wunused-variable] STATEMENT_BEGIN(Bind);
^ ../src/macros.h:146:9: note: expanded from macro 'STATEMENT_BEGIN' int status = napi_create_async_work(
^ ../src/statement.cc:396:5: warning: unused variable 'status' [-Wunused-variable] STATEMENT_BEGIN(Get);
^ ../src/macros.h:146:9: note: expanded from macro 'STATEMENT_BEGIN' int status = napi_create_async_work( \ 
^
../src/statement.cc:468:5: warning: unused variable 'status' [-Wunused-variable]
STATEMENT_BEGIN(Run); 
^
../src/macros.h:146:9: note: expanded from macro 'STATEMENT_BEGIN'
int status = napi_create_async_work(
^ ../src/statement.cc:538:5: warning: unused variable 'status' [-Wunused-variable] STATEMENT_BEGIN(All);
^ ../src/macros.h:146:9: note: expanded from macro 'STATEMENT_BEGIN' int status = napi_create_async_work( \ 
^ ../src/statement.cc:639:5: warning: unused variable 'status' [-Wunused-variable] STATEMENT_BEGIN(Each); ^
../src/macros.h:146:9: note: expanded from macro 'STATEMENT_BEGIN'
int status = napi_create_async_work(
^ ../src/statement.cc:766:5: warning: unused variable 'status' [-Wunused-variable] STATEMENT_BEGIN(Reset); 
^ ../src/macros.h:146:9: note: expanded from macro 'STATEMENT_BEGIN' int status = napi_create_async_work( \ 
^
7 warnings generated. 
SOLINK_MODULE(target) Release/obj.target/node_sqlite3.node 
COPY Release/node_sqlite3.node
COPY /storage/emulated/0/Bots/Test/node_modules/sqlite3/lib/binding/napi-v3-android-arm/node_sqlite3
TOUCH Release/obj.target/action_after_build.stamp make: Leaving directory '/storage/emulated/0/Bots/Test/node_modules/sqlite3/build' 
npm WARN Test@1.0.0 No description
npm WARN Test@1.0.0 No repository field.

+sqlite3@5.0.2 added 43 packages from 109 contributors and audited 146 packages in 451.474s 

5 packages are looking for funding run npm fund for details
found 
2 high severity vulnerabilities
run npm audit fix to fix them, or npm audit for details

是的,它在 5 分钟后安装,但是当您使用 sqlite3 运行代码时,它会引发错误:

$ node test                         
internal/modules/cjs/loader.js:1122                 
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: dlopen failed: couldn't map "/storage/emulated/0/Bots/Test/node_modules/sqlite3/lib/binding/napi-v3-android-arm/node_sqlite3.node" segment 1: Permission denied
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)                         
    at Module.load (internal/modules/cjs/loader.js:928:32)                                              
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)                                    
    at Module.require (internal/modules/cjs/loader.js:952:19)                                           
    at require (internal/modules/cjs/helpers.js:88:18)                                                  
    at Object.<anonymous> (/storage/emulated/0/Bots/Test/node_modules/sqlite3/lib/sqlite3-binding.js:4:15)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)

测试.js:

var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('db.sqlite3');

我还在 github 上创建了一个问题,但没有人在那里回答我: https ://github.com/mapbox/node-sqlite3/issues/1491

4

1 回答 1

0
npm install sqlite3 --build-from-source --sqlite=/data/data/com.termux/files/usr/bin/sqlite3
于 2022-03-04T10:46:45.207 回答