如何修复 Node.js 错误,例如“gyp ERR!找到 VS,包括“使用 C++ 进行桌面开发”工作负载。”当我启动 Nuxt.js 项目时

2023-12-30

我在最新的项目中使用了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 安装程序安装了带有 C++ 的“Visual Studio”。 但仍然发生同样的错误。

我尝试在管理员的PowerShell中使用“windows-build-tools”命令。 命令就是这样。

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

但仍然发生同样的错误。 我认为节点版本可能很高,所以我需要将节点版本“14.15.1”降低到“14.10.1”。 但从来没有解决我的问题。

我几乎放弃了,但是 nuxt.js 安装正确。 我必须解决它。 我搜索了很多次但无法修复。 请有人建议我吗?请......


我跟着这页。 https://github.com/nodejs/node-gyp首先,我在“C:\Users\your user name\build”中制作了 binding.gyp 文件,如下所示。

    {
    "targets": [{
        "target_name": "binding",
        "sources": [ "binding.vcxproj" ]
    }]
}

我的代码“sources”绑定到“VS ++C”。 在窗口命令提示符下运行以下命令↓

$ node-gyp configure
↓
$ node-gyp configure --msvs_version=2019※I already installed vs_version=2019
↓
$ node-gyp build

就是这样 !这是用 Node.js 传递 C++ 的非常简单的方法。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何修复 Node.js 错误,例如“gyp ERR!找到 VS,包括“使用 C++ 进行桌面开发”工作负载。”当我启动 Nuxt.js 项目时 的相关文章

随机推荐