使用 Electron-builder 构建 Electronjs 应用程序时,包含另一个 NodeJS 应用程序(通过 child_process 运行)

发布于 2025-01-14 19:27:10 字数 1269 浏览 4 评论 0原文

  1. 我有一个 Electronjs 应用程序,它通过 child_process 运行 NodeJS 应用程序,它创建一个 JSON 文件作为输出,并且该 JSON 文件通过 IPC 发送到客户端。
    它在开发中按预期工作模式。但是,如果使用 Electron-builder 构建此 electrojs 应用程序,则它不包含该 Nodejs 应用程序,因此我收到一条错误消息,提示 no such file or directory open ${timestamp}.json (此文件应由该 Nodejs 应用程序创建)。

此错误构建后显示

  1. 这是项目结构

在此处输入图像描述

  1. 一些代码示例是 这里
{
  "name": "electron-ipc",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "build": "electron-builder -w -c.extraMetadata.main=main.js"
  },
  "extraFiles": [
    "anotherNodeJsApp"
  ],
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^17.1.2",
    "electron-builder": "^22.14.13"
  }
}

  1. I have an electronjs app that is run a nodejs app via child_process and it creates a JSON file as output and this JSON file is being sent to the client via IPC.
    It working as expected in development mode. But if build this electronjs app using electron-builder it's not included that nodejs app, so I'm getting an error says no such file or directory open ${timestamp}.json (This file should be created by that nodejs app).

This error shown after build

  1. Here is the project structure

enter image description here

  1. Some code example is here,
{
  "name": "electron-ipc",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "build": "electron-builder -w -c.extraMetadata.main=main.js"
  },
  "extraFiles": [
    "anotherNodeJsApp"
  ],
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^17.1.2",
    "electron-builder": "^22.14.13"
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文