Electron 如何只添加几个模块?

Electron how to add only few modules?

我正在尝试使用 Electron-packager 构建我的 Electron 应用程序。问题是我的 Electron 应用程序使用 node-notifier 模块。打包的时候,我用的是这个命令:

electron-packager . MahApp --ignore='node_modules|.sass-cache|src' --platform=darwin --arch=x64

但问题是命令会忽略所有节点模块。所以我这样编辑:

electron-packager . MahApp --ignore='node_modules\/(?!node-notifier).+|.sass-cache|src' --platform=darwin --arch=x64

它似乎有效,因为只有 'node_modules/node-notifier' 在 resources/app 中。但它不会工作,因为 node-notifier 模块本身在 node_modules 目录下有额外的节点模块,如下所示:

./MahApp/node_modules/node-notifier/node_modules/...

所以它不起作用,因为任何依赖项都不存在。我在 --ignore_path 中的正则表达式也忽略了 node_notifier 中的 node_modules 内部。我不知道我现在该怎么办。我试过这样指定相对路径:

--ignore='./node_modules\/(?!node-notifier).+|...'

但是没用。

你真的需要节点通知模块吗?如果没有,您可以 npm uninstall node-notifier --save,或者仅将其放在开发依赖项中,并 运行 使用 --prune 选项