javascript - 无法启动 Electron 打包的 JS 应用程序。未捕获的 TypeError : require. nodeRequire 不是函数

标签 javascript web-applications electron

我通过 Electron 打包了我们的 JS Web 应用程序.
当我尝试启动此打包应用程序时出现以下错误:

text.js: Uncaught TypeError: require.nodeRequire is not a function

我们的 RequireJS 版本中没有函数 nodeRequire。
据我了解,NodeJS 的 RequireJS 版本与浏览器的 RequireJS 版本不同。
我应该怎么做才能解决这个问题?
我应该在我们的网络应用程序中使用其他版本的 RequireJS 吗?
或者是否可以配置 Electron 来避免此错误?

最佳答案

Electron 提供了一个适合我的配置。

// In the main process
var mainWindow = new BrowserWindow({
  webPreferences: { nodeIntegration: false }
});

关于javascript - 无法启动 Electron 打包的 JS 应用程序。未捕获的 TypeError : require. nodeRequire 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38147438/

相关文章:

node.js - 从现有 Exe 创建适用于 Windows 应用商店的应用程序包

javascript - jquery.event.drag - 为每拖动 X 个像素运行脚本

visual-studio - 如何在 Visual Studio IDE 中将 Web 应用程序项目自动打包 (MSDeploy) 作为项目构建的一部分?

azure - 如何使用Azure Powershell更改Azure WebApp的堆栈?

node.js - MAC OS X "open APP.app"和 "APP.app/content/MacOs/APP"shell 脚本之间的差异

javascript - Electron 应用程序 : Turn off On-Screen Keyboard Windows 10 Tablet

javascript - 如何找到本地安装的npm模块依赖于某个模块?

javascript - 从命令行执行 HTML Javascript

javascript - 如何从json数组中获取特定值?

java - 如何读取放置在 war 之外的属性文件?