node.js - 无法使用 npm 安装 sqlite3 依赖项
问题描述
我正在运行 Pop!_OS (Ubuntu) 20.04。当我尝试将 sqlite3 添加到我的 nodejs 项目的依赖项中时,我收到了这堵警告墙:
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
> sqlite3@5.0.1 install /home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.1/napi-v6-linux-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for sqlite3@5.0.1 and node@14.15.4 (node-v83 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/kevinlopez/Documents/Projects/wsky-be/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-3320300/sqlite3.c
/bin/sh: 1: python: not found
make: *** [deps/action_before_build.target.mk:13: Release/obj/gen/sqlite-autoconf-3320300/sqlite3.c] Error 127
make: Leaving directory '/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Linux 5.8.0-7630-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6"
gyp ERR! cwd /home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3
gyp ERR! node -v v14.15.4
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64 --napi_version=7 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1048:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Linux 5.8.0-7630-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.15.4
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64 --napi_version=7 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
npm WARN wsky-be@1.0.0 No description
npm WARN wsky-be@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@5.0.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@5.0.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kevinlopez/.npm/_logs/2021-01-17T06_26_58_042Z-debug.log
我尝试卸载并重新安装 npm 和 nodejs,删除并重新安装 node_modules 和 package-lock.json,删除 ~/.node-gyp 和 running npm i -g node-gyp
,并安装构建要素sudo apt-get install -y build-essential
这是我的 package.json:
{
"name": "wsky-be",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-session": "^1.17.1",
"helmet": "^4.3.1",
"knex": "^0.21.15"
},
"devDependencies": {
"nodemon": "^2.0.7"
}
}
解决方案
我认为这个问题来自最新版本的 sqlite3。尝试npm install sqlite3@4.1.1
并使用它。它非常适合我
推荐阅读
- python - 如何在 Plotly 美国飞行地图示例中根据航空公司更改颜色
- c# - 根据当前时间更改标签
- html - 在 a 下面添加垂直空间
element in a table
- c++ - nm符号“U”和“T”,这是什么意思?
- sharepoint - 使用 PowerShell 在 SharePoint 中检查术语名称时出现与号问题
- react-admin - 无法让 react-admin 在内部工作
标记(包括 React-Admin 在另一个 Redux 应用程序中) - c++ - How can I refresh the console in the most efficient way? (snake game c++)
- botframework - 从 Visual Studio 2017 发布 BOT
- c# - 使用内置的 ASP.NET Core Web 服务器构建 .NET Core 控制台应用程序?
- llvm - 如何使用 IRBuilder - LLVM 6.0 加载在单独函数中分配的地址