I am making an Electron Angular app using electron-edge-js to avoid having to run a server to transition between angular and C# code. The app works as long as I don't actually call edge to do anything, but fails (at build) with:
Module not found: Error: Can't resolve 'fs' (or 'path') in ... node_modules\electron-edge-js\lib.
I have tried every solution I can find online. I used angular-builders\custom-webpack and was able to get the application to build, but the next error I got was 'require is not defined'.
The code can be found here: https://github.com/pdpete/AngularElectronEdgeQuickstart
In 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;
});
}
}
As far as I can tell, after a bunch of research, Angular 5 and above do not allow access to fs (or other node modules), so it is impossible to write an Edge app with an Angular version > 5.