简体   繁体   English

使用带有通知程序的 pkg 构建 node.js 可执行文件

[英]Build node.js executable using pkg with notifier

I'm using pkg to package my node app into an.exe and it is working fine.我正在使用 pkg 到 package 我的节点应用程序到 an.exe,它工作正常。 The problem I have though is that the module notifier isn't included in the build.我遇到的问题是模块通知程序不包含在构建中。 When I run the following command to build the exe:当我运行以下命令来构建 exe 时:

$ pkg . --targets node10-win-x64

I get this:我明白了:

> pkg@4.4.6
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\notifu\notifu.exe
  %2: path-to-executable/notifier/notifu.exe
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\notifu\notifu64.exe
  %2: path-to-executable/notifier/notifu64.exe
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\terminal-notifier.app\Contents\MacOS\terminal-notifier
  %2: path-to-executable/notifier/terminal-notifier
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\snoreToast\SnoreToast.exe
  %2: path-to-executable/notifier/SnoreToast.exe
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\notifu\notifu.exe
  %2: path-to-executable/notifier/notifu.exe
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\notifu\notifu64.exe
  %2: path-to-executable/notifier/notifu64.exe
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\terminal-notifier.app\Contents\MacOS\terminal-notifier
  %2: path-to-executable/notifier/terminal-notifier
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\snoreToast\SnoreToast.exe
  %2: path-to-executable/notifier/SnoreToast.exe

This seems to be a common issue, it has been brought to light here , but I can't get this working with that user's information.这似乎是一个常见问题,已在此处曝光,但我无法使用该用户的信息来解决此问题。 Am I supposed to move notifu.exe to the directory where my node's main.js is?我应该将 notifu.exe 移动到我的节点 main.js 所在的目录吗?

I solved it.我解决了。 On Windows 10 (64bit) In my project, I used "node-notifier" and I got a warning similar to the above.在 Windows 10 (64bit) 上,在我的项目中,我使用了“node-notifier”,并收到了与上述类似的警告。 The above alert is a warning that the executable must be in a subfolder after it has been created.上述警报是一个警告,即可执行文件在创建后必须位于子文件夹中。

However, in Windows 10 (64-bit), "node-notifier" uses "soreToast-x64.exe" rather than "soreToast.exe".但是,在 Windows 10(64 位)中,“node-notifier”使用“soreToast-x64.exe”而不是“soreToast.exe”。

You can proceed in the following order.您可以按以下顺序进行。

  1. Reinstall pkg to the latest version.将 pkg 重新安装到最新版本。

npm i -g pkg npm i -g pkg

  1. Find and copy "snoretoast-x64.exe" from the "\node_modules\node-notifier~" subfolder.从“\node_modules\node-notifier~”子文件夹中查找并复制“snoretoast-x64.exe”。

  2. Create a folder "notifier" in the generated executable subpath and copy and paste "snoretoast-x64.exe".在生成的可执行子路径中创建一个文件夹“notifier”并复制并粘贴“snoretoast-x64.exe”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM