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

相关推荐
mldong1 小时前
你的 Vue3 项目也能有钉钉同款审批流设计器:npm 装包,10 分钟画出第一条审批流
前端·vue.js
2分钟速写快排2 小时前
什么是 RAG?如何用 RAG 实现一个用户记忆?
前端·后端·ai编程
passerby60612 小时前
如何自己造一个时间处理库
前端·javascript·github
走到天涯海角3 小时前
react里面的长列表渲染优化
前端·react.js·前端框架
小羊没烦恼!3 小时前
Hello Web API系列教程——Web API与国际化
java·服务器·前端·javascript·php
北岛贰4 小时前
迷茫焦虑期,我做了一个带支付带官网的 AI 聊天虚拟恋人 App
前端·人工智能·后端
mayaairi5 小时前
Vue2 组件通讯(三):全局事件总线、PubSub、插槽与组件实例属性
前端·javascript·vue.js
kyriewen6 小时前
面试官问我:AI 都能写代码了,前端凭什么还值 25K
前端·javascript·人工智能
风骏时光牛马7 小时前
AI源码分析:拆解模型底层实现逻辑
前端
IT_陈寒7 小时前
React子组件莫名其妙重渲染?你可能漏了这个Hook
前端·人工智能·后端