Не удается разрешить 'fs' или 'path' Edge-js и Angular - PullRequest
0 голосов
/ 30 апреля 2019

Я создаю приложение Electron Angular с использованием Electron-Edge-Js, чтобы избежать необходимости запуска сервера для перехода между 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 notfined».

Код можно найти здесь: 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;
    });
  }
}

1 Ответ

0 голосов
/ 10 мая 2019

Насколько я могу судить, после нескольких исследований Angular 5 и выше не разрешают доступ к fs (или другим модулям узлов), поэтому невозможно написать приложение Edge с версией Angular> 5.

...