gpt4 book ai didi

node.js - "id"参数必须是字符串类型。接收类型对象

转载 作者:行者123 更新时间:2023-12-03 12:40:36 25 4
gpt4 key购买 nike

我是 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();
}
});

这里出了什么问题?

最佳答案

你的问题在这里

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

通过以下修复
const { app, BrowserWindow } = require('electron');

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

关于node.js - "id"参数必须是字符串类型。接收类型对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61500332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com