我正在使用pkg将节点应用打包到.exe中,并且工作正常。我遇到的问题是模块 notifier 未包含在构建中。当我运行以下命令来构建exe时:
$ pkg . --targets node10-win-x64
我明白了:
> 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
这似乎是一个常见的问题,已经here被发现,但是我无法使用该用户的信息。我应该将notifu.exe移到节点的main.js所在的目录吗?
答案 0 :(得分:1)
我解决了。在 Windows 10(64 位)上 在我的项目中,我使用了“node-notifier”,并收到了与上述类似的警告。 上面的警告是一个警告,即可执行文件在创建后必须位于子文件夹中。
但是,在 Windows 10(64 位)中,“node-notifier”使用“soreToast-x64.exe”而不是“soreToast.exe”。
您可以按以下顺序进行。
npm i -g pkg
从“\node_modules\node-notifier~”子文件夹中找到并复制“snoretoast-x64.exe”。
在生成的可执行子路径中创建文件夹“notifier”并复制粘贴“snoretoast-x64.exe”。