首页 > 解决方案 > 当我捆绑电子程序时,找不到路径中发生了一些错误;

问题描述

代码库是可以重现的在这里: https://github.com/xiaobindebingo/electron-app.git 我的想法是使用 tsc 编译来构建目录;然后将 package.json main配置为init.js,这需要('./build/main.js'); 它在开发中可以正常工作,但在捆绑应用程序中是错误的;当我启动捆绑的应用程序时;像这样有问题


错误信息 在此处输入图像描述

{
  "name": "ide",
  "version": "1.0.0",
  "description": "小程序开发工具",
  "main": "init.js",
  "scripts": {
    "build": "tsc",
    "watch": "tsc -w",
    "lint": "eslint -c .eslintrc --ext .ts ./src",
    "start": "yarn build && electron .",
    "dist": "electron-builder"
  },
  "repository": {
    "type": "git",
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^13.1.2",
    "eslint": "^7.28.0",
    "typescript": "^4.3.2",
    "electron-builder": "^22.11.7"
    "@typescript-eslint/eslint-plugin": "^4.26.1",
    "@typescript-eslint/parser": "^4.26.1"
  }
}

require('./build/main.js');

标签: electronelectron-builderelectron-packager

解决方案


推荐阅读