首先,我不知道我遇到的问题是由于 webpack 或 electron-builder 还是两者的组合。
到问题。当我为开发而构建时,我可以在我的 package.json 文件中指定的 main.js 文件中使用已安装的节点模块{"main" : "app/main.js"}
。
但是,当我使用电子生成器创建安装程序时。当我使用安装程序安装应用程序时,我在启动应用程序时收到以下错误消息:
我的猜测是我收到此消息是因为 main.js 找不到所需的节点模块。那么如何让它们可用呢?
我希望有人比我更聪明,我们更擅长谷歌搜索:)
包.js:
{
"main": "app/main.js",
"scripts": {
"hot-server": "node hot-server.js",
"build-bundle": "rimraf app/dist.release && better-npm-run build-bundle",
"start": "better-npm-run start",
"start-hot": "better-npm-run start-hot",
"backend": "node backend-dummy.js",
"dist-win": "npm run build-bundle && rimraf dist && build --win --ia32",
"dist-mac": "npm run build-bundle && rimraf dist && build --mac"
},
"betterScripts": {
"start": {
"command": "electron ./",
"env": {
"NODE_ENV": "production"
}
},
"start-hot": {
"command": "electron ./",
"env": {
"HOT": 1,
"NODE_ENV": "development"
}
},
"build-bundle": {
"command": "webpack --config webpack.config.production.js --progress --profile --colors",
"env": {
"NODE_ENV": "production"
}
}
},
"bin": {
"electron": "./node_modules/.bin/electron"
},
"build": {
"appId": "app",
"files": [
"dist.release/*",
"dist.resources/*",
"main.js",
"thirdparty/*",
"app.html"
],
"extraFiles": [
"lang/*",
{
"from": "build/extra",
"to": "./",
"filter": "**/*"
}
],
"asar": true
}