下载node-gyp依赖包报错:gyp ERR! find VS msvs_version not set from command line or npm config

当遇到Node.js的编译错误提示不支持VS2013时,需要下载最新版VisualStudio,尤其是VisualStudio2017的生成工具,并确保安装WindowsSDK。设置msvs_version为2017,可能还需降低Node.js版本以避免兼容性问题。使用nvm管理Node.js版本,稳定版v14.17.0是一个好的选择。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错界面如下:

在这里插入图片描述

在这里插入图片描述

问题:not looking for VS2013 as it only supported up to Node.js 8

解决方案:

you need to install the lastest version of version of Visual Studio
你需要下载最新的Visual Studio

找到GitHub地址:https://github.com/nodejs/node-gyp
在这里插入图片描述

下载Vistual Studio链接:https://visualstudio.microsoft.com/zh-hans/thank-you-downloading-visual-studio/?sku=BuildTools

在这里插入图片描述

不要立刻就去选择c++桌面开发,这样下载的会是Vistual Studio生成工具2022,这个下载之后,还是会出错

没有选择windows SDK
在这里插入图片描述

Vistual Studio生成工具2022下载还是不行
在这里插入图片描述

下载Vistual Studio2017, 让windows支持c++编译环境

关闭弹窗,选择可用里面的Vistual Studio2017,社区版,个体开发人员就足够了
在这里插入图片描述

看清楚是Vistual Studio2017,我已经安装过了,所以截图时是修改状态
在这里插入图片描述

勾选一个windows sdk

一定要勾选一个windows sdk
在这里插入图片描述

npm config set msvs_version 2017

然后cmd输入:npm config set msvs_version 2017,然后就可以在项目工程里安装node-gyp了

如果还是出错,像下面这样报错,可能是node版本过高导致的
在这里插入图片描述

在这里插入图片描述

降低node版本,可以用nvm管理node版本

在这里插入图片描述

使用稳定版就v14.17.0就很完美了
下载: nvm add v14.17.0
使用:nvm use v14.17.0
在这里插入图片描述

总结:

  1. windows没有c++编译环境,所以要下载Vistual Studio
  2. windows没有设置msvs_version,所以下载之后,还需要使用命令行设置
  3. 注意node版本
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 unknown version "undefined" found at "D:\Program Files\Microsoft Visual Studio\2022\Community" gyp ERR! find VS unknown version "undefined" found at "D:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use 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 (D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:121:47) gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:74:16 gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:351:14) gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:70:14 gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:372:16 gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\util.js:54:7 gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\util.js:33:16 gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) gyp ERR! stack at ChildProcess.emit (node:events:527:28) gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) gyp ERR! System Windows_NT 10.0.26100 gyp ERR! command "D:\\MyApp\\nodejs\\node.exe" "D:\\迅雷下载\\mayidaijia-xiaochengxu_1.0.1\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-sass gyp ERR! node -v v16.15.1 gyp ERR! node-gyp -v v7.1.2
最新发布
03-17
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值