简体   繁体   中英

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. 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:

$ 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?

I solved it. On Windows 10 (64bit) In my project, I used "node-notifier" and I got a warning similar to the above. 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".

You can proceed in the following order.

  1. Reinstall pkg to the latest version.

npm i -g pkg

  1. Find and copy "snoretoast-x64.exe" from the "\node_modules\node-notifier~" subfolder.

  2. Create a folder "notifier" in the generated executable subpath and copy and paste "snoretoast-x64.exe".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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