在Visual Studio 2015中构buildnode-gyp项目时发生LNK1104错误

我已经尝试了一切,我有正确版本的Python(Python27),安装了Windows SDK 8.1,也安装了Visual C ++,但构build仍然失败。 我正在使用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中,看看这个项目是否至less可以从那里build立和运行,而不是。

请帮助我看了所有关于这个问题的其他问题,但他们的解决scheme都没有帮助我。

在这里输入图像说明

花了很多研究,但我find了解决scheme。 首先,要摆脱MSB8020错误,可以添加VisualStudioVersion环境variables,并将其设置为您的Visual Studio版本,或使用此标志/p:VisualStudioVersion=14.0 (在我的情况下)执行node-gyp build /p:VisualStudioVersion=14.0 node-gyp build

我解决了这个问题之后,我确实得到了不同的错误,我相信他们是值得一提的。

错误MSB4175然后出现,基本上表明它无法findMicrosoft.Build.Tasks.v12.0.dll (做这个.dllsearch找出它通常位于),复制并粘贴到它正在寻找的path为了它。

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

之后node-gyp应该没有错误地构build。