Closed code-ric closed 2 years ago
After hours of digging through issues in other repositories I was able to find a way to get it working.
First of all I added terserOptions
to the webpack.config.main.prod.ts
that tell webpack to not compress vars as suggested in this issue :
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
compress: {
reduce_vars: false,
},
},
}),
],
},
Right after that I got another error which indicated that I had another native module not added to the /release/app/package.json
file. So I added it as a dev dependency in the parent folder and as a regular dependency in the app-folder.
Next I did an npm run rebuild
and npm run package
which resulted in a working executable for me.
I hope that some people find this helpful in the future :)
After hours of digging through issues in other repositories I was able to find a way to get it working.经过几个小时的挖掘其他存储库中的问题后,我找到了一种让它工作的方法。
First of all I added
terserOptions
to thewebpack.config.main.prod.ts
that tell webpack to not compress vars as suggested in this issue :首先,我将terserOptions
添加到webpack.config.main.prod.ts
中,告诉 webpack 不要按照本期中的建议压缩变量:optimization: { minimizer: [ new TerserPlugin({ parallel: true, terserOptions: { compress: { reduce_vars: false, }, }, }), ], },
Right after that I got another error which indicated that I had another native module not added to the
/release/app/package.json
file. So I added it as a dev dependency in the parent folder and as a regular dependency in the app-folder.之后我收到另一个错误,表明我有另一个本机模块未添加到/release/app/package.json
文件中。因此,我将其添加为父文件夹中的开发依赖项以及应用程序文件夹中的常规依赖项。Next I did an
npm run rebuild
andnpm run package
which resulted in a working executable for me.接下来我做了一个npm run rebuild
和npm run package
,这为我生成了一个可以工作的可执行文件。I hope that some people find this helpful in the future :)我希望有些人将来会发现这有帮助:)
"Thank you, brother. It has resolved my issue."
Prerequisites
main
branchDEBUG_PROD=true npm run build && npm start
Expected Behavior
The executable(s) under
\release\build
andrelease\build\win-unpacked
should be working.Current Behavior
Both executables print the following JavaScript error:
Steps to Reproduce
These are just guesses what could be the reason for the cause:
Install and use a native module as a dev dependency like this
Include the dependency in the
release/app/package.json
Run
npm i
resulting in:husky - Git hooks installed
added 1 package, and audited 1532 packages in 20s
[1] [1] > build:renderer [1] > cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.prod.ts [1] [0] [0] > build:main [0] > cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.main.prod.ts [0] [1] npm run build:renderer exited with code 0 [0] npm run build:main exited with code 0 • electron-builder version=23.0.3 os=10.0.19043 • loaded configuration file=package.json ("build" field) • writing effective config file=release\build\builder-effective-config.yaml • rebuilding native dependencies dependencies=electron-overlay-window@2.0.1 platform=win32 arch=x64 • packaging platform=win32 arch=x64 electron=18.0.3 appOutDir=release\build\win-unpacked • building target=nsis file=release\build\ElectronReact Setup 4.5.0.exe archs=x64 oneClick=true perMachine=false • building block map blockMapFile=release\build\ElectronReact Setup 4.5.0.exe.blockmap