解决方法
在环境变量中配置 Visual Studio
下面是我的配置, 需要根据自己的电脑进行修改
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64
解决思路
根据报错信息 找不到我的 Visual Studio,
直接查看 环境变量 或者 在本地运行 cl.exe , 进行判断.
配置环境变量之后 成功安装
报错截图
PS F:\electron\demo\electron-demo> npm install sqlite3 --save --build-from-source
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:\electron\demo\electron-demo\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 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@20.15.0 | win32 | x64
npm error gyp info find Python using Python version 3.12.2 found at "C:\Python312\python.exe"
npm error gyp ERR! find VS
npm error gyp ERR! find VS msvs_version not set from command line or npm config
npm error gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm error gyp ERR! find VS checking VS2022 (17.9.34723.18) found at:
npm error gyp ERR! find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm error gyp ERR! find VS - found "Visual Studio C++ core features"
npm error gyp ERR! find VS - found VC++ toolset: v143
npm error gyp ERR! find VS - missing any Windows SDK
npm error gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm error gyp ERR! find VS looking for Visual Studio 2015
npm error gyp ERR! find VS - not found
npm error gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm error gyp ERR! find VS
npm error gyp ERR! find VS **************************************************************
npm error gyp ERR! find VS You need to install the latest version of Visual Studio
npm error gyp ERR! find VS including the "Desktop development with C++" workload.
npm error gyp ERR! find VS For more information consult the documentation at:
npm error gyp ERR! find VS
https://github.com/nodejs/node-gyp
#on-windows
npm error gyp ERR! find VS **************************************************************
npm error gyp ERR! find VS
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm error gyp ERR! stack at VisualStudioFinder.fail (F:\electron\demo\electron-demo\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm error gyp ERR! stack at F:\electron\demo\electron-demo\node_modules\node-gyp\lib\find-visualstudio.js:75:16
udio.js:363:14)
npm error gyp ERR! stack at F:\electron\demo\electron-demo\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm error gyp ERR! stack at F:\electron\demo\electron-demo\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm error gyp ERR! stack at F:\electron\demo\electron-demo\node_modules\node-gyp\lib\util.js:54:7
npm error gyp ERR! stack at F:\electron\demo\electron-demo\node_modules\node-gyp\lib\util.js:33:16
npm error gyp ERR! stack at ChildProcess.exithandler (node:child_process:430:5)
npm error gyp ERR! stack at ChildProcess.emit (node:events:519:28)
npm error gyp ERR! stack at maybeClose (node:internal/child_process:1105:16)
npm error gyp ERR! System Windows_NT 10.0.22631
npm error gyp ERR! command "D:\nodejss\node.exe" "F:\electron\demo\electron-demo\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
npm error gyp ERR! cwd F:\electron\demo\electron-demo\node_modules\sqlite3
npm error gyp ERR! node -v v20.15.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\sc\AppData\Local\npm-cache_logs\2024-07-05T03_04_08_020Z-debug-0.log