electron package can not find module xml2json

问题

electron 打包好的应用找不到xml2json

但是开发环境npm start 运行正常

定位

node_modules没有包含在打的包中,

解决办法

--no-prune

Be careful not to include node_modules you don't want into your final app. If you put them in the devDependencies section of package.json, by default none of the modules related to those dependencies will be copied in the app bundles. (This behavior can be turned off with the --no-prune flag.) In addition, folders like .git and node_modules/.bin will be ignored by default. You can use --ignore to ignore files and folders via a regular expression (not a glob pattern). Examples include --ignore=.gitignore or --ignore=".git(ignore|modules)".

electron-packager ./ --platform linux --arch=x64 --overwrite --no-prune

原文地址:https://www.cnblogs.com/mayidudu/p/5865267.html