无法解析 'fs' 或 'path' Edge-js 和 Angular

Can't resolve 'fs' or 'path' Edge-js and Angular

我正在使用 electron-edge-js 制作一个 Electron Angular 应用程序,以避免必须 运行 服务器在 angular 和 C# 代码之间转换。只要我实际上没有调用 edge 做任何事情,该应用程序就可以工作,但失败(在构建时):

Module not found: Error: Can't resolve 'fs' (or 'path') in ... node_modules\electron-edge-js\lib.

我已经尝试了所有可以在网上找到的解决方案。我使用 angular-builders\custom-webpack 并能够构建应用程序,但我遇到的下一个错误是 'require is not defined'.

代码可以在这里找到:https://github.com/pdpete/AngularElectronEdgeQuickstart

在app.component.ts中:

import { Component } from '@angular/core';
import * as Edge from 'electron-edge-js';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'The Wrong App Name';

  // if this is commented out, the app works fine, but with 'The Wrong App Name'
  constructor() {
    var getAppName = Edge.func({
      assemblyFile: "Controller.dll",
      typeName: "Controller.NameController",
      methodName: "GetName"
    });

    getAppName(null, function (error, result) {
      if (error) throw error;
      console.log(result);
      this.title = result;
    });
  }
}

据我所知,经过大量研究,Angular 5 及以上版本不允许访问 fs(或其他节点模块),因此不可能编写具有Angular 版本 > 5.