【问题标题】:Can't resolve 'fs' or 'path' Edge-js and Angular无法解析“fs”或“路径”Edge-js 和 Angular
【发布时间】:2019-04-30 01:53:27
【问题描述】:

我正在使用 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 并且能够构建应用程序,但我得到的下一个错误是“未定义要求”。

代码可以在这里找到: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;
    });
  }
}

【问题讨论】:

    标签: c# angular electron edgejs


    【解决方案1】:

    据我所知,经过大量研究,Angular 5 及以上版本不允许访问 fs(或其他节点模块),因此无法编写 Angular 版本 > 5 的 Edge 应用。

    【讨论】:

      猜你喜欢
      • 2019-03-17
      • 2021-06-05
      • 1970-01-01
      • 2018-07-06
      • 2020-03-16
      • 1970-01-01
      • 2019-04-09
      • 2019-01-28
      • 1970-01-01
      相关资源
      最近更新 更多