2

I'm developing an app with Electron and Angular 4. I want to show a dialog when I click a button to select a folder, but there is a problem with the electron API:

FS error I've seen a lot of people with the same problem but I couldn't find a solution to fix this. I've tried to modify the angular-cli config by adding a script that requires the fs module but it fails too...

My component looks like this:

import { Component, OnInit } from '@angular/core';
import { dialog } from 'electron';

@Component({
  selector: 'app-photos',
  templateUrl: './photos.component.html'
})
export class PhotosComponent implements OnInit {

  private path = '';
  private photos = ['A', 'B', 'C'];

  constructor() { }

  ngOnInit() {
  }

  openFolderSelector() {
    dialog.showOpenDialog({ properties: ['openDirectory'] }, (filepaths) => {
      console.log(filepaths);
    });
  }
}

Has anybody made it work?

Thanks for your help!

Juandi
  • 73
  • 1
  • 1
  • 7
  • Did you find a solution for your problem? I'm struggling with the same kind of error... – mu88 Mar 27 '18 at 17:16
  • https://stackoverflow.com/questions/41785295/fs-module-fails-when-integrating-electron-into-angular-project/50465430#50465430 – PaulCo May 22 '18 at 11:46

1 Answers1

0

Try to import "dialog" like this ?

const { dialog } = require('electron');

Source

Arpp
  • 301
  • 1
  • 11