在使用电子生成器生成EXE后找不到模块 [英] cannot find module 'sqlite3' after build exe with electron-builder

查看:0
本文介绍了在使用电子生成器生成EXE后找不到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在https://medium.com/jspoint/packaging-and-distributing-electron-applications-using-electron-builder-311fc55178d9

的帮助下构建了我的电子应用程序

成功(仅限Windows)。但在安装已发布的应用程序后,我收到如ScreenShort所示的错误

我的脚本如下

Package.json

  "name": "aux-services",
  "version": "1.0.0",
  "description": "Mobile Repair Tracking System",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "postinstall": "electron-builder install-app-deps",
      "pack": "electron-builder -w"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/shafeequeot/Mobile-Service-Tracker.git"
  },
  "author": "AuxWall",
  "email": "shafeequeot@gmail.com",
  "url": "https://auxwall.com",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/shafeequeot/Mobile-Service-Tracker/issues"
  },
  "homepage": "https://github.com/shafeequeot/Mobile-Service-Tracker#readme",
  "devDependencies": {
    "electron": "^11.1.1",
    "electron-builder": "^22.14.13",
    "sqlite3": "^5.0.2"
  },
  "dependencies": {
   
  }
}

电子生成器.json

{
    "appId": "com.auxWall.service",

    "productName": "Aux Services",
    "copyright": "AuxWall",
    "directories": {
        "app": ".",
        "output": "out",
        "buildResources": "build-res"
    },
    "files": [
        "package.json",
        "**/*",
        "node_modules"
    ],
    "dmg": {
        "background": null,
        "backgroundColor": "#ffffff",
        "window": {
            "width": "400",
            "height": "300"
        },
        "contents": [
            {
                "x": 100,
                "y": 100
            },
            {
                "x": 300,
                "y": 100,
                "type": "link",
                "path": "/Applications"
            }
        ]
    },
    "mac": {
        "target": "dmg",
        "category": "public.auxWall.services"
      },
    "win": {
        "target": "nsis"
    },
    "linux": {
        "target": "AppImage",
        "category": "Utility"
    }
}

有人能帮助我解决此问题吗?

推荐答案

如果在电子应用程序的正常运行期间需要sqlite3,而不仅仅是在开发期间,则需要将sqlite3添加为依赖项。

IE:从"devDependencies": { ... }移动到"dependencies": { ... }

package.json

{
  "name": "aux-services",
  "version": "1.0.0",
  "description": "Mobile Repair Tracking System",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "postinstall": "electron-builder install-app-deps",
      "pack": "electron-builder -w"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/shafeequeot/Mobile-Service-Tracker.git"
  },
  "author": "AuxWall",
  "email": "shafeequeot@gmail.com",
  "url": "https://auxwall.com",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/shafeequeot/Mobile-Service-Tracker/issues"
  },
  "homepage": "https://github.com/shafeequeot/Mobile-Service-Tracker#readme",
  "devDependencies": {
    "electron": "^11.1.1",
    "electron-builder": "^22.14.13"
  },
  "dependencies": {
    "sqlite3": "^5.0.2"   
  }
}

这篇关于在使用电子生成器生成EXE后找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆