node.js - 在 Visual Studio 2015 中构建 node-gyp 项目时出现 LNK1104 错误

标签 node.js visual-c++ msbuild visual-studio-2015 node-gyp

我已经尝试了一切,我有正确版本的Python(Python27),安装了Windows SDK 8.1,还安装了Visual C++,但构建仍然失败。顺便说一句,我正在使用 Visual Studio 2015 社区编辑器。当我尝试从 cmd 执行 node-gyp build 时,出现以下错误:

> C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.t
argets(44,5): error MSB8020: The builds tools for v140 (Platform Toolset = 'v14
0') cannot be found. To build using the v140 build tools, either click the Proj
ect menu or right-click the solution, and then select "Update VC++ Projects..."
. Install v140 to build using the v140 build tools. [C:\Users\Programming PC\Do
cuments\GitHub\node-addon-examples\1_hello_world\node_0.10\build\hello.vcxproj]

此错误促使我进入 Visual Studio 并查看该项目是否至少可以从那里构建并运行,但事实并非如此。

请帮助我查看了与此问题相关的所有其他问题,但他们的解决方案都没有帮助我。

enter image description here

最佳答案

进行了大量研究,但我找到了解决方案。首先,要消除 MSB8020 错误,请添加 VisualStudioVersion 环境变量并将其设置为您的 Visual Studio 版本,或者执行 node-gyp build > 使用此标志 /p:VisualStudioVersion=14.0 (就我而言)。

在解决这个问题后,我实际上遇到了不同的错误,我相信它们非常值得一提。

错误MSB4175然后出现,基本上表明它找不到Microsoft.Build.Tasks.v12.0.dll(对此.dll进行搜索以找到出其通常所在的位置),将其复制并粘贴到正在查找的路径中。

现在最重要的是,最后一个中断 node-gyp 的错误是因为缺少 .lib 文件。 Npm 不会创建以下文件 ...\.node-gyp\4.3.1\Debug\node.lib。所以你需要去here下载一个node.lib和mkdir Debug\并将node.lib放在那里。

之后,node-gyp 应该会正确构建。

关于node.js - 在 Visual Studio 2015 中构建 node-gyp 项目时出现 LNK1104 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35823097/

相关文章:

javascript - Node.js - TypeError : res. json 不是函数(在某些路由中工作,在其他路由中不起作用)

javascript - Isotope.js 和 Webpack - 可能吗?

visual-studio-2008 - Visual Studio 2010 和 Windows 2000

c - 需要在IDA Pro中解读C代码

visual-studio-2010 - 使用 MSBuild 和 CruiseControl .NET 构建和部署 VS2010 数据库项目

c# - MsBuild XmlPeek 结果拆分值

javascript - 有没有更好的方法来访问 package.json 中的数组数据

javascript - 使用node.js创建大文件

c++ - 模板编程 : ambiguous call to overloaded function

msbuild - MSBuild 的有用任务