Build node.js executable using pkg with notifier

3.9k Views Asked by At

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:

> [email protected]
> 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?

1

There are 1 best solutions below

0
MrMonkey On

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