npm install sqlite3时报错解决

在nodejs项目里想安装sqlite3

输入下面代码后报错

复制代码
npm install sqlite3

npm warn deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated npmlog@6.0.2: This package is no longer supported.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated are-we-there-yet@3.0.1: This package is no longer supported.
npm warn deprecated gauge@4.0.4: This package is no longer supported.
npm error code 1
npm error path F:\bjy_docu\Internet_media\more\more\node_modules\sqlite3
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install -r napi || node-gyp rebuild
npm error prebuild-install warn install connect ECONNREFUSED 127.0.0.1:443
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@8.4.1
npm error gyp info using node@22.20.0 | win32 | x64
npm error (node:35676) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
npm error (Use `node --trace-deprecation ...` to show where the warning was created)
npm error gyp info find Python using Python version 3.13.7 found at "E:\develop\python3.13.7\python.exe"
npm error gyp info find VS using VS2019 (16.11.35931.194) found at:
npm error gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
npm error gyp info find VS run with --verbose for detailed information
npm error gyp info spawn E:\develop\python3.13.7\python.exe
npm error gyp info spawn args [
npm error gyp info spawn args   'F:\\bjy_docu\\Internet_media\\more\\more\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm error gyp info spawn args   'binding.gyp',
npm error gyp info spawn args   '-f',
npm error gyp info spawn args   'msvs',
npm error gyp info spawn args   '-I',
npm error gyp info spawn args   'F:\\bjy_docu\\Internet_media\\more\\more\\node_modules\\sqlite3\\build\\config.gypi',
npm error gyp info spawn args   '-I',
npm error gyp info spawn args   'F:\\bjy_docu\\Internet_media\\more\\more\\node_modules\\node-gyp\\addon.gypi',
npm error gyp info spawn args   '-I',
npm error gyp info spawn args   'C:\\Users\\bai\\AppData\\Local\\node-gyp\\Cache\\22.20.0\\include\\node\\common.gypi',
npm error gyp info spawn args   '-Dlibrary=shared_library',
npm error gyp info spawn args   '-Dvisibility=default',
npm error gyp info spawn args   '-Dnode_root_dir=C:\\Users\\bai\\AppData\\Local\\node-gyp\\Cache\\22.20.0',
npm error gyp info spawn args   '-Dnode_gyp_dir=F:\\bjy_docu\\Internet_media\\more\\more\\node_modules\\node-gyp',
npm error gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\bai\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\22.20.0\\\\<(target_arch)\\\\node.lib',
npm error gyp info spawn args   '-Dmodule_root_dir=F:\\bjy_docu\\Internet_media\\more\\more\\node_modules\\sqlite3',
npm error gyp info spawn args   '-Dnode_engine=v8',
npm error gyp info spawn args   '--depth=.',
npm error gyp info spawn args   '--no-parallel',
npm error gyp info spawn args   '--generator-output',
npm error gyp info spawn args   'F:\\bjy_docu\\Internet_media\\more\\more\\node_modules\\sqlite3\\build',
npm error gyp info spawn args   '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error Traceback (most recent call last):
npm error   File "F:\bjy_docu\Internet_media\more\more\node_modules\node-gyp\gyp\gyp_main.py", line 42, in <module>
npm error     import gyp  # noqa: E402
npm error     ^^^^^^^^^^
npm error   File "F:\bjy_docu\Internet_media\more\more\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 9, in <module>
npm error     import gyp.input
npm error   File "F:\bjy_docu\Internet_media\more\more\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 19, in <module>
npm error     from distutils.version import StrictVersion
npm error ModuleNotFoundError: No module named 'distutils'
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: `gyp` failed with exit code: 1
npm error gyp ERR! stack     at ChildProcess.onCpExit (F:\bjy_docu\Internet_media\more\more\node_modules\node-gyp\lib\configure.js:259:16)
npm error gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
npm error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm error gyp ERR! System Windows_NT 10.0.26100
npm error gyp ERR! command "E:\\develop\\Nodejs22\\node.exe" "F:\\bjy_docu\\Internet_media\\more\\more\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm error gyp ERR! cwd F:\bjy_docu\Internet_media\more\more\node_modules\sqlite3
npm error gyp ERR! node -v v22.20.0
npm error gyp ERR! node-gyp -v v8.4.1
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: C:\Users\bai\AppData\Local\npm-cache\_logs\2025-10-09T08_28_41_296Z-debug-0.log

使用了网上大部分的方法没有用

最后通过下面解决

  1. 将Python设置到系统变量里
  1. 在终端使用下方代码安装

    npm install sqlite3@5.1.6 --registry=https://registry.npmjs.org --verbose

相关推荐
jzlhll1231 小时前
kotlin Flow first() last()总结
开发语言·前端·kotlin
蓝冰凌2 小时前
Vue 3 中 defineExpose 的行为【defineExpose暴露ref变量】详解:自动解包、响应性与实际使用
前端·javascript·vue.js
奔跑的呱呱牛2 小时前
generate-route-vue基于文件系统的 Vue Router 动态路由生成工具
前端·javascript·vue.js
柳杉2 小时前
从动漫水面到赛博飞船:这位开发者的Three.js作品太惊艳了
前端·javascript·数据可视化
Greg_Zhong3 小时前
前端基础知识实践总结,每日更新一点...
前端·前端基础·每日学习归类
We་ct3 小时前
LeetCode 148. 排序链表:归并排序详解
前端·数据结构·算法·leetcode·链表·typescript·排序算法
IT_陈寒3 小时前
JavaScript开发者必看:5个让你的代码性能翻倍的隐藏技巧
前端·人工智能·后端
还是大剑师兰特4 小时前
Vue3 中 computed(计算属性)完整使用指南
前端·javascript·vue.js
井川不擦4 小时前
前端安全通信方案:RSA + AES 混合加密
前端