报错信息:
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (D:\..\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack at D:\..\frontend\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\..\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
npm ERR! gyp ERR! stack at D:\..\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack at D:\..\node_modules\node-gyp\lib\find-visualstudio.js:401:16
npm ERR! gyp ERR! stack at D:\..\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at D:\..\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:420:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:302:5)
解决方案
1、先下载:
下载方式1:
以管理员权限打开cmd,在项目目录下执行:
npm install --global --production windows-build-tools
构建完成后,会在C:\Users\电脑用户名
目录下创建.windows-build-tools
文件夹
下载方式2:
直接去官网进行下载下载 Visual Studio Tools - 免费安装 Windows、Mac、Linux
2、下载完成后:
运行vs_BuildTools.exe,勾选C++生成工具进行安装,重新运行npm install 即可
若vs为2022版本的,则勾选C++的桌面开发