VS 代码“gyp ERR!找到 VS”

Posted

技术标签:

【中文标题】VS 代码“gyp ERR!找到 VS”【英文标题】:VS Code "gyp ERR! find VS" 【发布时间】:2020-11-12 16:57:17 【问题描述】:

尽管我已经搜索以解决此错误,但我找不到任何合适的解决方案。

安装了具有完整 C++ 开发人员工具的 Visual Studio 2019 以及 Python。 无论如何,当我在 VSCode 中安装 bcryptjs 时出现此错误:

gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\BOSS\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at findVisualStudio2013 (C:\Users\BOSS\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16)
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\BOSS\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at findVisualStudio2015 (C:\Users\BOSS\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14)
gyp ERR! stack     at regSearchKeys (C:\Users\BOSS\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16)
gyp ERR! stack     at regGetValue (C:\Users\BOSS\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7)
gyp ERR! stack     at C:\Users\BOSS\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:301:5)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\BOSS\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\BOSS\Coding\PROJECTS\UDEMY\NODE.JS BOOTCAMP 2020\natours\node_modules\node-pty
gyp ERR! node -v v10.22.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN natours@1.0.0 No description
npm WARN natours@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted "os":"darwin","arch":"any" (current: "os":"win32","arch":"x64")
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-pty@0.9.0 (node_modules\node-pty):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-pty@0.9.0 install: `node scripts/install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

有人知道可以做些什么来消除这个错误吗? 我已经设置了npm config set msvs_version 2019 --global,但我仍然得到VCINSTALLDIR not set, not running in VS Command Promptcould not use PowerShell to find Visual Studio 2017 or newer

顺便说一句,bcryptjs 本身正在安装,但我认为没有一些额外的东西?

当我使用 yarn 时,整个编译过程运行良好,所以我认为这是一个我找不到的烦人的配置错误。

有没有手动设置VS目录的方法? 我已经尝试过这个解决方案https://***.com/a/59882818/13609359,但没有成功。

非常感谢提前 斯莱文

【问题讨论】:

【参考方案1】:

好吧,在挣扎了两个多小时后,我想出了这个解决方案:

npm install --global --production windows-build-tools

没有简单的方法可以确定您需要安装一个额外的包来完成编译(yarn 应该是开箱即用的)。 希望这个解决方案也可以帮助其他人,因为安装涉及编译过程的软件包似乎是一个大问题。

【讨论】:

做了这个,但似乎仍然不适合我。

以上是关于VS 代码“gyp ERR!找到 VS”的主要内容,如果未能解决你的问题,请参考以下文章

vs2019使用网上别人写好的代码

我在VS2010里写的代码能成功运行,但是用VS2017RC打开源代码就有很多错误

VS写代码注释内容怎么对齐

VS2013如何显示代码运行所用时间

在VS中怎样调试JS代码

VS2010,C#,如何设置复制代码的时候自动缩进对齐???