Reactjs 电子反应web应用程序不想打开?

Reactjs 电子反应web应用程序不想打开?,reactjs,electron,Reactjs,Electron,因此,我的web应用程序使用npm i正常运行和打开,然后npm启动。现在,在我运行npm启动后,它会在瞬间打开,然后关闭 [0] Starting the development server... [0] [0] Files successfully emitted, waiting for typecheck results... [1] [1] wait-on http://localhost:3000 && electron . exited with code 0

因此,我的web应用程序使用npm i正常运行和打开,然后npm启动。现在,在我运行npm启动后,它会在瞬间打开,然后关闭

[0] Starting the development server...
[0]
[0] Files successfully emitted, waiting for typecheck results...
[1]
[1] wait-on http://localhost:3000 && electron . exited with code 0
当我在本地主机上打开chrome时,它会向我发送此错误

TypeError:window.require不是函数 模块../src/components/header/header.component.tsx

  24 | 
  25 | import { Link } from 'react-router-dom';
  26 | 
> 27 | const electron = window.require('electron');
  28 | const ipcRenderer  = electron.ipcRenderer;
  29 | 
  30 | 

还有其他人遇到这个问题吗?对于开发人员来说,它运行良好,但对我来说不行

请通过编辑将您正在使用的电子版本以及创建
浏览器窗口
实例(包括选项)的主流程部分添加到您的问题中。由于electron 5(或4?我再也不确定了)出于安全原因,默认情况下未启用节点集成。如果没有节点集成或重新引入
require
函数的预加载脚本,渲染器过程中就没有
require
。如果您的开发人员使用比您旧的electron版本运行此操作,这可能已经解释了该行为。