node-gyp的使用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了node-gyp的使用相关的知识,希望对你有一定的参考价值。

参考技术A 安装python的时候,需要将path添加到环境变量,安装程序默认没有选择,记得选择

参照 npm相关配置

参照 nvm使用

node-gyp 错误找不到要使用的任何 Visual Studio 安装

【中文标题】node-gyp 错误找不到要使用的任何 Visual Studio 安装【英文标题】:node-gyp error Could not find any Visual Studio installation to use 【发布时间】:2022-01-15 19:05:55 【问题描述】:

我遇到的问题是我无法为项目安装软件包,它不断出错:

npm ERR! npm ERR! gyp ERR! find VS valid versions for msvs_version:
npm ERR! npm ERR! gyp ERR! find VS
npm ERR! npm ERR! gyp ERR! find VS **************************************************************
npm ERR! npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! npm ERR! gyp ERR! find VS **************************************************************

我试图听从其他人的这些帖子的建议:

How to fix node.js error like "gyp ERR! find VS including the "Desktop development with C++" workload." when I launch Nuxt.js project

还有这个How can I solve error gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config?

但似乎都没有帮助。

到目前为止我做了什么:

我用Desktop development with C++MSVC v143 - VS 2022 C++ x64/x86 build tools 安装了最新的VS Code(2022 社区)

我已将msvs_version 配置为具有2022 的值,我使用npm config set msvs_version=2022node-gyp configure --msvs_version=2022 做到了这一点

我尝试安装 Windows 构建工具 npm install --global --production windows-build-tools 但它只是说 ...Node.js now incldues build tools for Windows...

我还使用上面列出的第二篇文章中的命令手动构建了 node-gyp node-gyp configure node-gyp configure --msvs_version=2022 node-gyp build 及其所有的绿色和好的

我不知道我还能做什么

【问题讨论】:

【参考方案1】:

经过几个小时的搜索,我发现了问题,这是我的节点版本,我当时是 16.x.x,我安装了节点版本管理器并移至版本 14,它可以工作。

【讨论】:

以上是关于node-gyp的使用的主要内容,如果未能解决你的问题,请参考以下文章

如何让 node-gyp 在 Windows 7 平台上工作

node-gyp 在安装过程中失败 web3 scrypt@6.0.3 install: `node-gyp rebuild`

Windows 使用 node-gyp

node-gyp的使用

需要 node-gyp 的 npm install 在 Windows 上失败

npm install 时卡在了node-gyp rebuild