【问题标题】:The "id" argument must be of type string. Received type object“id”参数必须是字符串类型。接收到的类型对象
【发布时间】:2020-04-29 19:38:06
【问题描述】:

我是 Electron js 的初学者。当我创建我的第一个应用程序并运行时,我收到了这个错误。

TypeError [ERR_INVALID_ARG_TYPE]:“id”参数必须是字符串类型。接收到的类型对象

下面是编写的代码。

const electron = require("electron");

const { app, BrowserWindow } = require(electron);

let createWindow = () => {
  let window = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true,
    },
  });

  // load the index.html file
  window.loadFile("index.html");

  window.webContents.openDevTools();
};

app.whenReady().then(createWindow);

// Quit when all windows closed
app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
  }
});

app.on("active", () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow();
  }
});

这里出了什么问题?

【问题讨论】:

    标签: node.js npm electron


    【解决方案1】:

    你的问题来了

    const { app, BrowserWindow } = require(electron);
    

    通过以下修复

    const { app, BrowserWindow } = require('electron');
    

    这是因为require() 需要一个字符串作为参数。

    【讨论】:

      猜你喜欢
      • 2020-06-20
      • 2019-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-13
      • 2021-01-05
      • 2019-11-27
      • 1970-01-01
      相关资源
      最近更新 更多