我有一个主要过程的电子申请如下:
const {app, BrowserWindow, Menu, dialog} = require('electron');
const path = require('path')
let logConfig = require('./js/loggConfig.js');
....
直接从终端运行时,这将完美执行
但是,当我使用电子构建器打包此项目,并将其安装在另一台计算机(Windows 10)上时,启动应用程序时出现以下错误:
Error: Cannot find module '.js/loggConfig.js'
如何解决此问题?
以下是我package.json
的样子:
{
"name": "ABCD",
"version": "0.0.1",
"description": "...",
"author": "abcd <abcd@gmail.com>",
"homepage": "http://www.abcd.com",
"main": "main_electron.js",
"scripts": {
"postinstall": "install-app-deps",
"start": "electron .",
"dist": "build"
},
"build": {
"appId": "yourappid",
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
],
"category": "Video"
},
"win": {
"target": "NSIS",
"icon": "build/icon.ico",
"extraResources": [
]
}
},
"dependencies": {
"electron-context-menu": "^0.9.1",
"electron-log": "^2.2.13",
"fs": "0.0.1-security",
"mkdirp": "^0.5.1",
"path": "^0.12.7",
"uuid": "^3.1.0",
"xmlbuilder": "^9.0.4",
"zip-folder": "^1.0.0"
},
"devDependencies": {
"electron": "^1.7.9",
"electron-builder": "^19.49.0"
}
}