TypeError: electron.BrowserWindow.addDevToolsExtension is not a function

来源:-6 使用 IPC 进行通信

幽辰

2020-05-27

使用devtron 工具的时候报错
图片描述

const {app, BrowserWindow, ipcMain} = require('electron')
const path = require('path')
app.on("ready", () => {
  require("devtron").install();
  const mainWindow = new BrowserWindow({
    height: 1200,
    webPreferences: { // 确定webPage的属性
      nodeIntegration: true, // 表示可以在electron中使用node
      preload: path.join(__dirname, "preload.js"),
    },
    width: 1600
  });
  mainWindow.loadFile("index.html");
  mainWindow.webContents.openDevTools();
  ipcMain.on("message", (event, arg) => {
    console.log(arg);
  });
});

经过本人测试,是require("devtron").install();这条语句的问题,一旦加上,则会报之前的错,不加,则运行成功

写回答

2回答

张轩

2020-05-28

同学你好 刚刚使用了和你一摸一样的源代码进行测试 发现没有这个错误 可否告知你 electron 的版本?我的版本是 7.1.1  我还发现你的 devtron路径在 node_modules 是带有下划线的目录 _devtron 而我安装的是没有下划线的 devtron,请你重新安装一下 devtron 试试。

npm install --save-dev devtron

1
3
张轩
回复
慕仙8092207
同学你好 devtron 已经处于不维护的状态了 新版 electron 是不支持的,只能用 electron5 版本才能兼容,我建议你不要使用这个插件啦
2021-12-10
共3条回复

aoyeebay

2020-07-02

Installing Devtron from C:\Users\ceshi\electron-quick-start\node_modules\devtron
(electron) 'BrowserWindow.getDevToolsExtensions' is deprecated and will be removed. Please use 'session.getAllExtensions' instead.
(electron) 'BrowserWindow.addDevToolsExtension' is deprecated and will be removed. Please use 'session.loadExtension' instead.
(node:13128) UnhandledPromiseRejectionWarning: Error: Loading extension at C:\Users\aoyeebay\electron-quick-start\node_modules\devtron failed with: The 'manifest_version' key must be present and set to 2 (without quotes). See developer.chrome.com/extensions/manifestVersion.html for details.
(node:13128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13128) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

老师,我的electron版本9.0.5,Devtron版本1.4.0,截至目前最新版吧,然后用了您课程上的代码require("devtron").install() 到这一句报错,并且chrome开发工具里没有多一个Devtron,是不是这个插件不更新了?

0
0

2024更新 Electron+React+七牛云实战跨平台桌面应用

开发一款自动云同步的 Markdown 文件管理软件

1270 学习 · 468 问题

查看课程