错误 TS2305:模块“"http"”没有导出成员 'OutgoingHttpHeaders'。尝试将电子更新程序添加到电子项目中时

error TS2305: Module '"http"' has no exported member 'OutgoingHttpHeaders'. when trying to add electron-updater into electron project

我正在使用 https://github.com/maximegris/angular-electron 样板来启动电子应用程序。克隆后,我只做了以下两处更改以开始设置自动更新程序:

安装电子更新程序:npm install electron-updater --save

main.ts 文件中的以下行:

import { autoUpdater } from 'electron-updater';

在此之后,当我尝试启动应用程序时出现以下错误:

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts(2,27): error TS2305: Module '"http"' has no exported member 'OutgoingHttpHeaders'.
node_modules/electron-updater/out/AppUpdater.d.ts(4,10): error TS2305: Module '"http"' has no exported member 'OutgoingHttpHeaders'.
node_modules/electron-updater/out/Provider.d.ts(3,10): error TS2305: Module '"http"' has no exported member 'OutgoingHttpHeaders'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! angular-electron@2.6.0 build:electron:main: `tsc main.ts --outDir dist && copyfiles package.json dist && cd dist && npm install --prod && cd ..`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the angular-electron@2.6.0 build:electron:main script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harshveer/.npm/_logs/2018-02-13T09_30_46_752Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! angular-electron@2.6.0 electron:serve: `npm run build:electron:main && electron ./dist --serve`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the angular-electron@2.6.0 electron:serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harshveer/.npm/_logs/2018-02-13T09_30_46_777Z-debug.log
ERROR: "electron:serve" exited with 2.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular-electron@2.6.0 start: `npm-run-all --parallel webpack:watch electron:serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the angular-electron@2.6.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harshveer/.npm/_logs/2018-02-13T09_30_46_902Z-debug.log

知道如何解决这个问题,

以这种方式导入 electron-updater 模块:const autoUpdater = require("electron-updater").autoUpdater 解决了问题。我在文档中遗漏了它:

Use autoUpdater from electron-updater instead of electron:

import { autoUpdater } from "electron-updater"

Or if you don't use ES6: const autoUpdater = require("electron-updater").autoUpdater

讨论 here 如果有人遇到问题。