npm/yarn安装sqlite3依赖报错

运行环境

1. node16

2. electron22

3. vue3

4 windows 11

问题描述

前端项目中添加了sqlite3的依赖后报错:

Command: node-pre-gyp install –fallback-to-build

Arguments:

Directory: XXXXX\node_modules\sqlite3

Output:

node-pre-gyp info it worked if it ends with ok

node-pre-gyp info using node-pre-gyp@1.0.11

node-pre-gyp info using node@16.15.0 | win32 | x64

node-pre-gyp info check checked for “xxxxx\node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-x64\node_sqlite3.node” (not found)

gyp ERR! configure error

gyp ERR! stack Error: Could not find any Visual Studio installation to use

截图如下:

在这里插入图片描述

解决办法

  1. 安装windows-build-tools

    npm install –g –production windows-build-tools

  2. 删掉lock文件、node_modules重新执行npm install / yarn 安装依赖

    npm install

无需安装visual studio 完美解决!!!

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/57c658a9c8.html