Electron 5.1.0 的 ZeroMQ 重建失败,出现错误 MSB4019:找不到导入的项目 "C:\Microsoft.Cpp.Default.props"

ZeroMQ Rebuild for Electron 5.1.0 fails with error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found

我正在尝试将 ZeroMQ 安装到 electron 应用程序中,但我无法为 electron 重建包。

我正在尝试在我的 Windows 10 机器上为 electron 5.1.0 安装 ZeroMQ。详情:

OS: Windows 10 电子:5.0.8 节点:12.0.0

根据 README.md https://github.com/zeromq/zeromq.js/ 中的说明,我遵循了以下程序:

1) 用 npm 安装 zeromq npm install zeromq

2) 电子重建 npm rebuild zeromq --runtime=electron --target=5.1.0 注:文档说明这里的target应该是Electron版本;但是,这会导致 404 错误,因为 npm 会尝试转到不存在的 https://nodejs.org/dist/v5.0.8/node-v5.0.8-headers.tar.gz。然后我想尝试节点版本,但这会导致 401 错误。然后我尝试了导致此错误的 zeromq 版本(5.1.0,如命令中所示):

error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

谷歌搜索这个错误会带来很多需要构建工具的 Whosebug 问题。向前看 README.md 让我想到可以使用下一个命令解决这个问题。

3) 安装 visual studio 构建工具 npm install --global --production windows-build-tools 此命令已成功完成并安装构建工具和 python2.7

4) 重新运行第2步中的rebuild命令会导致同样的错误。我尝试了这个命令的变体: npm config set msvs_version 2013 也使用 2015 和 2017。

2013 和 2015 给出了这个错误: error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. gyp ERR! build error gyp ERR! stack Error: C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23) gyp ERR! stack at ChildProcess.emit (events.js:198:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) gyp ERR! System Windows_NT 10.0.17134 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\<user>\path\to\app\node_modules\zeromq gyp ERR! node -v v10.16.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! zeromq@5.1.0 install: node scripts/prebuild-install.js || (node scripts/preinstall.js && node-gyp rebuild) npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the zeromq@5.1.0 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

虽然 2017 年给出了这个: error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 bui ld tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by select ing the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\<user>\path\to\app\node_modules\zeromq\build\zmq.vcxproj] 结尾部分与其他年份相似。

最后这是一个 visual studio 构建工具安装错误。我使用 visual studio 安装程序卸载了 visual studio,然后重新安装了 windows-build-tools。