node.js - 吉普错误!构建错误 - 如果未定义 npm_config_node_gyp

标签 node.js windows visual-studio npm package.json

在我运行“npm install”后出现这些错误,我运行了“npm install --g --production windows-build-tools”,我还删除了 node_modules、package-lock.json 并安装了 Visual Studio community 2019 但仍然有同样的问题......

enter image description here enter image description here enter image description here

C:\Users\myuser\Documents\GitHub\myRepo\node_modules\snappy> if not defined npm_config_node_gyp
"C:\Users\myuser\Documents\GitHub\myRepo\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )
 else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
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 checking VS2019 (16.7.30621.155) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - missing any VC++ toolset
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 - found in "C:\Program Files (x86)\Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
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:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:20
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:315:5)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1047:16)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Users\myuser\Documents\GitHub\myRepo\node_modules\\node_modules\\node\\bin\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\myuser\Documents\GitHub\myRepo\node_modules\snappy
gyp ERR! node -v v14.10.1
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok

我使用的 Nodejs 版本是:v12.8.1 和 NPM版本:6.10.2

运行“npm install”后,我应该怎么做才能消除该错误?

最佳答案

我建议在管理模式下使用 power-shell 命令安装依赖项 npm install --global windows-build-tools

关于node.js - 吉普错误!构建错误 - 如果未定义 npm_config_node_gyp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64578469/

相关文章:

windows - Very Sleepy 在捕获 MinGW 编译文件时看不到函数名称

windows - 从cygwin命令提示符执行 “hadoop version”时显示不正确的路径

windows - 在过滤器 Parsed_concat_0 上找不到未标记输入垫 1 的匹配流

javascript - Grunt 登录已注册的任务?

javascript - Node.js ReadStream 从不调用 'data' 监听器

json - NodeJS HttpGet 到带有 JSON 响应的 URL

c# - 如何检测我的 .NET 程序集是从网站运行还是从桌面计算机运行?

windows - 使用CMake在Visual Studio中构建ARM64 ASM

c# - visual studio 输出窗口不显示

javascript - 将 HTML 文件内容传递给 JavaScript 变量