npm错误 gyp错误 vs版本不对msvs_version 不兼容 windows SDK 报错

执行更新GYP 语句

npm install -g node-gyp

最新的GYP 好像已经不支持Python 2.7 版本,npm 会提示你 更新都3.*.*版本

安装 Node.js 的时候一定要勾选 以下这个 , 会自动检测安装缺少的环境
在这里插入图片描述

第一种方案

管理员运行 CMD (Power Shell 也行)
执行更新工具集

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

第二种方案

它会提示你当然 GYP 的vs 版本不匹配,会不断的递增去查询
执行设置指定 sdk 版本

npm config set msvs_version 2019

错误示例

npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.1.0
npm ERR! gyp info using node@16.4.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.6 found at "C:\Users\l\AppData\Local\Programs\Python\Python39\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 version 2015
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS checking VS2019 (16.10.31515.178) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v142
npm ERR! gyp ERR! find VS - found Windows SDK: 10.0.19041.0
npm ERR! gyp ERR! find VS - msvs_version does not match this version
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
npm ERR! gyp ERR! find VS valid versions for msvs_version:
npm ERR! gyp ERR! find VS - "2019"
npm ERR! gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
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 **************************************************************

都是相对比较基础性的问题,Node最多的就是版本问题,太多版本,太容易出错了,稍微多看看 【警告、错误】提示就能解决问题。


持续记录一下个人所遇到的问题

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐