node-gyp编译报错问题

1,677 阅读1分钟

node-gyp编译报错

gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@14.8.0 | win32 | x64
gyp info find Python using Python version 3.8.5 found at “C:\Program Files\Python38\python.exe”
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
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 **************************************************************

在开发过程中,依赖中如果含有对node-gyp的依赖,那么就需要有以下几个必须安装的软件:

  1. python3.x(先自行下载并安装3.9.9)
  2. Virsual Studio 2015(及以上版本)

缺少任何一样,否则就会报错,导致无法 npm install

node-gyp开源项目介绍中关于依赖的说明

\

解决方法

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

注意:这个过程比较慢,原因是:

  1. 他会去下载一套 Visual Studio MSBuilder的工具;
  2. 还需要一套Window SDK;
  1. 安装完成之后再去 npm install 有依赖于 node-gyp的项目就都是ok的;

安装完之后大约3-4个G,在win10的安装程序列表中出现的: