Angular 角度应用程序在electron中打开,但不在浏览器中打开

Angular 角度应用程序在electron中打开,但不在浏览器中打开,angular,typescript,electron,node-modules,require,Angular,Typescript,Electron,Node Modules,Require,在main.js文件中,我声明: webPreferences: { nodeIntegration: true } 因此,我可以在electron中打开应用程序,但在浏览器中我有一个错误: TypeError: window.require is not a function 在我的组件中,我的require electron出现错误,现在我使用: declare var window: Window; declare global { interface Window {

在main.js文件中,我声明:

webPreferences: {
  nodeIntegration: true
}
因此,我可以在electron中打开应用程序,但在浏览器中我有一个错误:

TypeError: window.require is not a function
在我的组件中,我的require electron出现错误,现在我使用:

declare var window: Window;
declare global {
  interface Window {
    process: any;
    require: any;
  }
}
const electron = window.require('electron');

我尝试了很多方法,但浏览器无法识别window.require函数。

为什么调用
const electron=window.require('electron')应用程序中?因为我需要将最大化/最小化和关闭功能从组件传递到初始化electron的main.js。所以,如果您在应用程序中运行electron,那么它如何在浏览器中工作?这就是为什么浏览器中出现window.require错误?如果您希望应用程序在浏览器中运行,则不能在浏览器中使用electron。