node.js - 如何修复 node.js 错误,例如“gyp ERR!查找 VS,包括“使用 C++ 进行桌面开发”工作负载。” 当我启动 Nuxt.js 项目时
问题描述
我在我的最新项目中使用了 Nuxt.js,并更换了新 PC 来开发我的项目。所以我安装了 node.js 和我通常的程序一样。然后我在命令中启动了“create-nuxt-app”使用的新 nuxt.js 项目。但是,出现如下错误消息。
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
我认为此错误消息取决于 node.js。因此,我遵循了这些错误消息,并在我的 Windows PC 中使用 Visual Studio Installer 安装了带有 C++ 的“Visual Studio”。但仍然发生同样的错误。
我尝试在管理员的 PowerShell 中使用“windows-build-tools”命令。命令就是这样。
npm install --global --production windows-build-tools
但仍然发生同样的错误。我认为节点版本可能很高,所以我需要将节点版本“14.15.1”降低到“14.10.1”。但永远不要解决我的问题。
我几乎放弃了,但 nuxt.js 安装正确。我必须修复它。我搜索了很多次,但我无法修复它。请有人给我建议吗?请......
解决方案
我跟着这个页面。 首先,我在“C:\Users\your user name\build”中创建了 binding.gyp 文件,如下所示。
{
"targets": [{
"target_name": "binding",
"sources": [ "binding.vcxproj" ]
}]
}
我的代码“源”绑定到“VS ++C”。在窗口命令提示符下运行命令↓</p>
$ node-gyp configure
↓
$ node-gyp configure --msvs_version=2019※I already installed vs_version=2019
↓
$ node-gyp build
而已 !用 node.js 传递 c++ 是非常简单的方法。
推荐阅读
- c# - LINQ中的双数之和
- wordpress - 安装失败:您的网站出现严重错误
- asp.net-core - 无法在 IIS 上托管 .Net Core 3.1 Web API
- python - 将 django 从 1.8 升级到 2.2.0
- visual-studio-code - 无法编辑过去的第 1 组
- firebase - Firebase 消息传递的安全性
- vuejs2 - Vuejs SPA 从第三方 api 更改元标记内容
- python-3.x - BrokenPipeError:-Errno- 32 损坏的管道
- php - 如果邮件正文 phpmailer 中的条件
- jdbc - 具有 SQL Server 集成安全性的 Flyway