【问题标题】:Electron how to add only few modules?Electron 如何只添加几个模块?
【发布时间】:2016-06-20 01:07:04
【问题描述】:

我正在尝试使用 Electron-packager 构建我的 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' 在资源/应用程序内。但它不起作用,因为 node-notifier 模块本身在 node_modules 目录下有额外的节点模块,如下所示:

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

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

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

但它不起作用。

【问题讨论】:

  • 我试过这个:--ignore='^node_modules\\/(?!node-notifier).{0,}|\\.sass-cache|src' 但没有用。帮忙?

标签: regex node.js electron


【解决方案1】:

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

【讨论】:

  • 是的,我需要它。我的电子应用程序使用它来通知。如果没有这个,它将在执行时出错。
  • 那么你为什么要忽略它呢? @modernator
  • 我不想忽略它。我只想从打包时忽略的其他模块中排除 node-notifier 模块。这就是为什么我在标题中说“如何只添加几个模块”。
  • 那么您到底想忽略哪些模块?
  • 另外,您实际上可以将html5通知api与电子一起使用,您不需要额外的模块,除非它当然是一个cli应用程序?请参阅here 了解更多信息
猜你喜欢
  • 2018-06-03
  • 2019-02-23
  • 2018-03-28
  • 2014-11-30
  • 1970-01-01
  • 2016-06-19
  • 1970-01-01
  • 2020-07-07
  • 1970-01-01
相关资源
最近更新 更多