windows下yarn报错gyp ERR! find VS解决

windows下执行yarn install的时候出现报错:gyp ERR! find VS解决

今天做项目,操作系统为win10,执行yarn install的时候出现报错:gyp ERR! find VS

完整报错信息如下:

gyp ERR! find VS
gyp ERR! find VS msvs_version not 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, try re-running with '--loglevel silly' for more details
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:\myprogram\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\myprogram\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\myprogram\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\myprogram\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\myprogram\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\myprogram\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\myprogram\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:333:5)
gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
gyp ERR! stack     at maybeClose (node:internal/child_process:1067:16)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\\myprogram\\nodejs\\node.exe" "C:\\myprogram\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd D:\phpstudy_pro\WWW\my\xdshop\pc\node_modules\fibers
gyp ERR! node -v v16.3.0
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
RHEL users please run: `yum install gcc-c++` and `yum groupinstall 'Development Tools'`

分析报错原因:

find VS失败,就是说找到了我们的 python 3.8 环境,还缺少 VS 环境。

我们去它提示的 https://github.com/nodejs/node-gyp#on-windows 看一下,信息如下:

On Windows
Install the current version of Python from the Microsoft Store package.

Install tools and configuration manually:

Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio Community (using the "Desktop development with C++" workload)
Launch cmd, npm config set msvs_version 2017
If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.

To target native ARM64 Node.js on Windows 10 on ARM, add the components "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64".

解决办法1:

下载Visual Studio Build Tools,安装时勾选”Visual C++ build tools”选项。
下载地址:https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools

解决办法2:

下载Visual Studio Community,安装时勾选”Desktop development with C++“选项,对应的中文是”包含C++的桌面开发”选项。
下载地址:https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community

我用方法2解决了。

出处:www.l1mn.com

原文标题:windows下yarn报错gyp ERR! find VS解决

原文地址:https://www.l1mn.com/p/k3vrk3.html

本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

评论

皖ICP备2023023451号

Copyright © L1MN.COM 联系方式:l1mnfw@163.com