我按照Electron Forge page安装了Electron的模板.

npx create-electron-app my-new-app --template=typescript-webpack

在那之后,我会跑

npm run start

Inside my-new-app文件夹和以下错误消息在命令窗口中弹出

$ npm run start

> my-new-app@1.0.0 start
> electron-forge start

✔ Checking your system
✔ Locating Application

An unh和led rejection has occurred inside Forge:
Error: Expected plugin to either be a plugin instance or a { name, config } object but found @electron-forge/plugin-webpack,[object Object]

Electron Forge was terminated. Location:
{}

我在谷歌上搜索了一下,但没有人犯同样的错误. 我可以使用上述模板,而不会在一周前出现错误消息.所以,我复制了一周前制作的项目并运行.这是一次成功.但是,我运行以下命令

npm audit

有22个漏洞(3个中等,19个高). 错误包括

got  <11.8.5 
Severity: moderate

minimatch  <3.0.5
Severity: high

It could not fix by npm audit fixnpm audit fix --force. So, I fixed this error by rewriting package.jsonpackage-lock.json. Then I deleate node_modules folder 和 run npm install. These vulnerabilities are gone, but above my problem were again after I run npm run start.

我认为@electron-forge/plugin-webpack有问题. 然而,我不知道如何修复它.

先谢谢你.

推荐答案

在Package.json中config.forge个选项下的plugins字段是在以下 struct 中生成的:

      "plugins": [
        [
          "@electron-forge/plugin-webpack",
          {
            "mainConfig": "./webpack.main.config.js",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/renderer.ts",
                  "name": "main_window",
                  "preload": {
                    "js": "./src/preload.ts"
                  }
                }
              ]
            }
          }
        ]
      ]

将该 struct 更改为具有nameconfig个字段的对象:

      "plugins": [
        {
          "name": "@electron-forge/plugin-webpack",
          "config": {
            "mainConfig": "./webpack.main.config.js",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/renderer.ts",
                  "name": "main_window",
                  "preload": {
                    "js": "./src/preload.ts"
                  }
                }
              ]
            }
          }
        }
      ]

Node.js相关问答推荐

Twilio-获取呼叫录音不起作用的请求

Sveltekit停靠的应用程序找不到从Build导入的包

如何在.npmrc中添加 comments ?

为什么这个verifyToken函数从未被调用过?

Next.js 路由不起作用 - 页面未正确加载

Axios TypeError:将循环 struct 转换为 JSON

NodeJS:zlib.gzipSync 在不同平台上给出不同的明文输出

在构建完成后,将AddedFiles文件夹的内容复制到dist文件夹

AWS ECS 服务发现 Cors 问题?

Indexeddb 获取所有不同于特定值的记录

为什么后端开发需要单独的服务器?

Zod 模式中的self 数组

MongoDB Atlas中的聚合触发器不起作用

使用Typescript 时我应该避免循环导入吗?

仅显示用户在 Reactjs 中使用服务器端发布的帖子是 Node Js、Mongodb

即使部署成功,也不会触发 Firebase 函数来填充 Firestore 集合.为什么?

我应该在(Docker)容器中使用 forever/pm2 吗?

具有多个条件的mongoose 查找

如何从 npm 注册表中删除 npm 包?

mongo 可以 upsert 数组数据吗?