Loading Electronic Modules in Angular 2 TypeScript

My goal is to take Angular 2 5 minutes quick start and turn it into an Electron app. What can I do by adding a "pre-cooked electron".

angular running

What I can not do is use any of the extended generations of Electron - for example, writing to the file system.

I can create and run "Electrogram" , but when I try to use some of the main functions contained in it, I get an error message in the console of my Electron application:

Changed by app.component.ts

import { Component } from '@angular/core';
import { remote, ipcRenderer } from 'electron';
import { writeFile } from 'fs';

@Component({
  selector: 'my-app',
  template: '<h1>My First Angular 2 App</h1><button (click)="doSomething()">Do Something</button>'
})
export class AppComponent {

  doSomething() {
    writeFile("c:\temp\doSomething.txt", "some data");
  }
}

Error in DevTools console

Application does not work

How to configure the application to search for Electron modules in their correct places?

+4
1

- . , , .

Webpack:

Webpack app.js( ). import { readFile } from 'fs' . - Electrogram -.

.

SystemJs

SystemJS FS :

let remote = require('electron').remote;
let fs = remote.require('fs');
...
let data = fs.readFileSync(this.dbFilename);

, .

(PS. ? , ...)

+2

Source: https://habr.com/ru/post/1651000/


All Articles