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

相关推荐
heyCHEEMS2 小时前
切页回来组件消失了?一个浏览器渲染机制引起的容器高度坍塌 bug
前端·浏览器
iaku2 小时前
Prompt 不是玄学:写给前端的 Prompt 工程指南
前端·人工智能
爱丶不疚2 小时前
在 dsh 仓库里扒到的宝藏工作流:详解 .agents/notes 决策沉淀系统
前端·agent·vibecoding
喜欢睡觉3 小时前
从"送花"讲懂 JavaScript:对象、数据类型与代理模式
前端
渣波3 小时前
NestJS 企业级后端架构实战:从核心代码到工程化思维的深度重构
前端·typescript·nestjs
BreezeJiang3 小时前
别再背工厂模式了:NestJS 第一行代码就是它的工业级落地
前端·javascript
光影少年3 小时前
RN 常见性能问题:JS卡顿、UI卡顿、桥接通信耗时
前端·react native·react.js
liuxiaocheng3 小时前
文本生成的进阶:generateText / streamText 里迟早会撞上的东西
前端·后端·ai编程
嘟嘟07173 小时前
NestJS 入门:从 NestFactory 入口到 Module/Controller/Service 模块化结构一次讲清
typescript·node.js·nestjs
渣波3 小时前
深度解析工厂模式:从蜜雪冰城到 NestFactory,彻底搞懂“创建与使用分离”
前端·javascript