从node.js模块获取D9025警告和C1083错误…我没有想法

首先我必须清楚,我绝不是一个JavaScript大师。我只是非常热心,我喜欢学习新东西。

我正在运行带有SP1的Windows 7 Ultimate x64,Windows更新已打开,node.js是v0.10.22。 我已经用Visual Studio C ++ Express版本2008,2010和2012分别尝试了这个过程,每个.net框架都是按照更新顺序安装的。 我也尝试了最初的干净安装后,每个版本的最新服务包。

所以,从理论上说,我应该在某种程度上已经有了各种可能的组合……而且我仔细检查了环境variables,并且为了每个版本都重新启动,只是为了好的措施。 然而它仍然以同样的方式失败。

我设法跟踪回到尽可能多的模块( node-antsails等)中的node-gyp rebuild命令,这会抛出:

 E:\Temp\node-test\node_modules\node-ant\node_modules\usb>node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild Build started 2013/12/06 19:46:52. __________________________________________________ Project "E:\Temp\node-test\node_modules\node-ant\node_modules\usb\build\binding.sln" (default targets): Target ValidateSolutionConfiguration: Building solution configuration "Release|x64". Target Build: Target usb_bindings: VCBuild.exe E:\Temp\node-test\node_modules\node-ant\node_modules\usb\build\usb_bindings.vcproj "Release|x64" cl : Command line warning D9025: overriding '/MT' with '/MD' cl : Command line warning D9025: overriding '/MT' with '/MD' cl : Command line warning D9025: overriding '/MT' with '/MD' cl : Command line warning D9025: overriding '/MT' with '/MD' e:\temp\node-test\node_modules\node-ant\node_modules\usb\src\node_usb.h(5): fatal error C1083: Cannot open include file: 'string': No such file or directory e:\temp\node-test\node_modules\node-ant\node_modules\usb\src\node_usb.h(5): fatal error C1083: Cannot open include file: 'string': No such file or directory e:\temp\node-test\node_modules\node-ant\node_modules\usb\src\node_usb.h(5): fatal error C1083: Cannot open include file: 'string': No such file or directory Project : warning PRJ0018: The following environment variables were not found: Done building target "usb_bindings" in project "binding.sln" -- FAILED. Done building target "Build" in project "binding.sln" -- FAILED. Done building project "binding.sln" -- FAILED. Build FAILED. cl : Command line warning D9025: overriding '/MT' with '/MD' cl : Command line warning D9025: overriding '/MT' with '/MD' cl : Command line warning D9025: overriding '/MT' with '/MD' cl : Command line warning D9025: overriding '/MT' with '/MD' Project : warning PRJ0018: The following environment variables were not found: e:\temp\node-test\node_modules\node-ant\node_modules\usb\src\node_usb.h(5): fatal error C1083: Cannot open include file: 'string': No such file or directory e:\temp\node-test\node_modules\node-ant\node_modules\usb\src\node_usb.h(5): fatal error C1083: Cannot open include file: 'string': No such file or directory e:\temp\node-test\node_modules\node-ant\node_modules\usb\src\node_usb.h(5): fatal error C1083: Cannot open include file: 'string': No such file or directory 5 Warning(s) 3 Error(s) Time Elapsed 00:00:00.17 gyp ERR! build error gyp ERR! stack Error: `msbuild` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "C:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd E:\Temp\node-test\node_modules\node-ant\node_modules\usb gyp ERR! node -v v0.10.22 gyp ERR! node-gyp -v v0.11.0 gyp ERR! not ok npm ERR! usb@0.2.3 preinstall: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the usb@0.2.3 preinstall script. npm ERR! This is most likely a problem with the usb package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls usb npm ERR! There is likely additional logging output above. npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\\nodejs\\\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-ant" "--msvs_version=auto" npm ERR! cwd E:\Temp\node-test npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! E:\Temp\node-test\npm-debug.log npm ERR! not ok code 0 

我最新的和可能的最丰富的尝试,我发现我可以指定的Visual Studio构build工具,尝试使用…

 E:\Temp\node-test>npm install node-ant --msvs_version=auto 

…似乎=auto尝试检测环境variables(?)的版本。

我已经尝试指定以下每个版本,我在C:\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py文件中列出了它们,列出在=2008=2010=2012那些甚至没有达到上面列出的错误的程序,甚至会在以下错误的细微变化中失败,抱怨项目版本:

 E:\Temp\node-test>npm install node-ant --msvs_version=2008 npm http GET https://registry.npmjs.org/node-ant npm http 304 https://registry.npmjs.org/node-ant npm http GET https://registry.npmjs.org/usb npm http 304 https://registry.npmjs.org/usb > usb@0.2.3 preinstall E:\Temp\node-test\node_modules\node-ant\node_modules\usb > node-gyp rebuild E:\Temp\node-test\node_modules\node-ant\node_modules\usb>node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild build/binding.sln(1): Solution file error MSB5014: File format version is not recognized. MSBuild can only read solution files between versions 7.0 and 9.0, in clusive. gyp ERR! build error gyp ERR! stack Error: `msbuild` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "C:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd E:\Temp\node-test\node_modules\node-ant\node_modules\usb gyp ERR! node -v v0.10.22 gyp ERR! node-gyp -v v0.11.0 gyp ERR! not ok npm ERR! usb@0.2.3 preinstall: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the usb@0.2.3 preinstall script. npm ERR! This is most likely a problem with the usb package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls usb npm ERR! There is likely additional logging output above. npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\\nodejs\\\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-ant" "--msvs_version=2008" npm ERR! cwd E:\Temp\node-test npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! E:\Temp\node-test\npm-debug.log npm ERR! not ok code 0 

GitHub回购已经很长时间了,所以我认为可能没有意义(我要去search回购叉,只是注意到其中有32个),但是在Google的每个报告中,我都会帮助我findC1083: Cannot open include file:行,其余的行列出了它找不到的特定文件。与我的'string'部分相反。

这是我第一个问题,所以让我知道你是否需要更多的细节。 我是白天的Java软件testing人员,所以对于使用debugging工具我并不陌生。 现在我真的没有想法,任何人都能指出我解决这个头痛的方向……?

[编辑]仅供参考,以下是我发现的一些类似问题,我已经尝试了尽可能密切的build议。

  • 无法在Windows 7 x64 / VS2012上安装需要编译的节点模块
  • https://github.com/TooTallNate/node-gyp/issues/227
  • http://wishmesh.com/2011/04/fatal-error-c1083-cannot-open-include-file-ammintrin-h-no-such-file-or-directory/
  • https://github.com/nonolith/node-usb/issues/3

和官方回购问题清单中最相似的(未回答的)。

  • https://github.com/nonolith/node-usb/issues/19

[edit2]道歉的编辑,但另一点可能或可能不重要..我有CygWin安装,并包括在我的系统path。 老实说,我在Linux上感觉更舒适,所以我自然在Windows的cmd提示符下使用* nixterminal命令。 这可能会导致一些节点模块错误地检测Windows编译工具所需的* nix系统…?

find了我的问题的解决办法,如果有其他人有这些相同的错误发布在这里作为参考的答案。

简单的两步修正:

  • 通过Visual Studio开发人员命令提示符运行所有命令,我使用VS2012。
  • node-gyp npm install -g node-gyp为全局模块: npm install -g node-gyp
  • 在安装时指定VS版本: npm install sails --msvs_version=2012

到目前为止,这已经适用于我试过的每一个依赖于Visual Studio的包,在安装的时候构build它的一部分API。

我相信这也适用于VS2010; 在这种情况下,指定相应的--msvs_version