在使用电子生成器生成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"
}
}
相关文章