Javascript 电子应用程序可以';不需要来自html文件的ipc

Javascript 电子应用程序可以';不需要来自html文件的ipc,javascript,node.js,ipc,electron,Javascript,Node.js,Ipc,Electron,我有一个电子应用程序,我已经建立。在我的主进程中,我打开一个新窗口,其中包括: electron = require('electron') const {globalShortcut} = require('electron') const app = electron.app runnerWindow = new BrowserWindow({width: width, height: height}) var path = `file://${__dirname}/ap

我有一个电子应用程序,我已经建立。在我的主进程中,我打开一个新窗口,其中包括:

  electron = require('electron')
  const {globalShortcut} = require('electron')
  const app = electron.app
  runnerWindow = new BrowserWindow({width: width, height: height})
  var path = `file://${__dirname}/app/template/index.html`
  console.log(path)
  runnerWindow.loadURL(path)
  runnerWindow.webContents.openDevTools()
然后从html内部调用:

if (window.module) module = window.module;
const ipc = require('electron').ipcRenderer
我得到的错误是:

uncaughttypeerror:require(…)。ipcRenderer不是函数


为什么我不能从文件中要求ipc?我打开了其他窗口并使用ipc,但它不适用于此特定窗口。

看起来错误在于您试图执行
require('electron')。ipcRenderer()
(注意调用括号)@nem035我尝试添加(),同样的错误。另外,在我的另一个窗口代码中,我在不使用()的情况下调用了它。我的意思是,错误的存在是因为您正在添加()。@nem035我不确定要更改什么。这是导致错误的行:const ipc=require('electron')。ipc渲染器。你建议它是什么?我刚刚在我目前正在从事的电子项目中尝试过,而且:对我有效。因此,您的错误在其他地方-您需要在html文件中显示这两行之上的所有JS。(如果没有代码,为什么要还原
模块
?)