问题遇到的现象和发生背景
想在vue中安装heatmap绘制热力图,已经安装了visual studio 2022社区版并勾选了使用c++的桌面开发,但仍报错“ gyp ERR! stack Error: Could not find any Visual Studio installation to use”
其中一条报错内容为unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community"
(引号中是我的安装路径)
问题相关代码
npm install heatmap
运行结果及报错内容
E:\web\pipe-project\pipe-project>npm install heatmap
npm ERR! code 1
npm ERR! path E:\web\pipe-project\pipe-project\node_modules\canvas
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@16.3.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.8.3 found at "D:\python\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version was set from command line or npm config
npm ERR! gyp ERR! find VS - looking for Visual Studio installed in "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE"
npm ERR! gyp ERR! find VS running in VS Command Prompt, installation path is:
npm ERR! gyp ERR! find VS "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools"
npm ERR! gyp ERR! find VS - will only use this version
npm ERR! gyp ERR! find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS msvs_version does not match this VS Command Prompt or the
npm ERR! gyp ERR! find VS installation cannot be used.
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (E:\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
npm ERR! gyp ERR! stack at E:\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (E:\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:3
51:14)
npm ERR! gyp ERR! stack at E:\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
npm ERR! gyp ERR! stack at E:\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
npm ERR! gyp ERR! stack at E:\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at E:\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:333:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1067:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19044
npm ERR! gyp ERR! command "E:\\nodejs\\node.exe" "E:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd E:\web\pipe-project\pipe-project\node_modules\canvas
npm ERR! gyp ERR! node -v v16.3.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
我的解答思路和尝试过的方法
- 设置使用路径
npm config set msvs_version “C:\Program Files\Microsoft Visual Studio\2022\Community”,无效,仍然报错unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community" - 执行
npm install -g node-gyp
以及
npm i -g windows-build-tools
仍然无效,报错信息不变。我的主要疑问在于为什么已经安装了visual studio,却还报错unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community",最终导致找不到visual studio呢,期待各位高人的解答指点,谢谢!