question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hello, when I make the call

const {remote, ipcRenderer} = require(‘electron’); let {dialog} = remote;

Uncaught TypeError: fs.existsSync is not a function at Object.eval (index.js:6) at eval (index.js:10) at Object../node_modules/electron/index.js (vendor.bundle.js:687) at __webpack_require__ (inline.bundle.js:55) at eval (app.component.ts:7) at Object../src/app/app.component.ts (main.bundle.js:43) at __webpack_require__ (inline.bundle.js:55) at eval (app.module.ts:20) at Object../src/app/app.module.ts (main.bundle.js:59) at __webpack_require__ (inline.bundle.js:55)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
maximegriscommented, Apr 15, 2018

You have to use window.require(‘electron’).remote.Menu Please try this . It does work on Windows. electron.service.ts:

import { Injectable } from '@angular/core';

// If you import a module but never use any of the imported values other than as TypeScript types,
// the resulting javascript file will look as if you never imported the module at all.
import { ipcRenderer, Menu } from 'electron';
import * as childProcess from 'child_process';

@Injectable()
export class ElectronService {

  ipcRenderer: typeof ipcRenderer;
  childProcess: typeof childProcess;
  menu: typeof Menu;
  template = [
    {
      label: 'Edit',
      submenu: [
        {role: 'undo'},
        {role: 'redo'},
        {role: 'cut'},
        {role: 'copy'},
        {role: 'paste'},
        {role: 'pasteandmatchstyle'},
        {role: 'delete'},
        {role: 'selectall'}
      ]
    },
    {
      label: 'View',
      submenu: [
        {role: 'reload'},
        {role: 'forcereload'},
        {role: 'toggledevtools'},
        {role: 'resetzoom'},
        {role: 'zoomin'},
        {role: 'zoomout'},
        {role: 'togglefullscreen'}
      ]
    },
    {
      role: 'window',
      submenu: [
        {role: 'minimize'},
        {role: 'close'}
      ]
    }
  ];


  constructor() {
    // Conditional imports
    if (this.isElectron()) {
      this.ipcRenderer = window.require('electron').ipcRenderer;
      this.childProcess = window.require('child_process');
      this.menu = window.require('electron').remote.Menu;

      const menu = this.menu.buildFromTemplate(this.template);
      this.menu.setApplicationMenu(menu);
    }
  }

  isElectron = () => {
    return window && window.process && window.process.type;
  }

}
1reaction
maximegriscommented, Apr 15, 2018

You’re welcome 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

THE MENU | Official Trailer | Searchlight Pictures - YouTube
Now PlayingA couple (Anya Taylor-Joy and Nicholas Hoult) travels to a coastal island to eat at an exclusive restaurant where the chef (Ralph ......
Read more >
The Menu (2022) - IMDb
A young couple travel to a remote island to eat at an exclusive restaurant where the chef has prepared a lavish menu, with...
Read more >
MENU Scandinavian Design | Official U.S. Store ...
Buy Danish and Scandinavian Designer Furniture Lighting and Accessories for the home.
Read more >
The Menu (2022 film) - Wikipedia
The Menu is a 2022 American dark comedy horror film directed by Mark Mylod, written by Seth Reiss and Will Tracy, based on...
Read more >
The Menu - Searchlight Pictures
The Menu. NOW PLAYING ONLY IN THEATERS. A couple (Anya Taylor-Joy and Nicholas Hoult) travels to a coastal island to eat at an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found