簡體   English   中英

使用帶有通知程序的 pkg 構建 node.js 可執行文件

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

我正在使用 pkg 到 package 我的節點應用程序到 an.exe,它工作正常。 我遇到的問題是模塊通知程序不包含在構建中。 當我運行以下命令來構建 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

這似乎是一個常見問題,已在此處曝光,但我無法使用該用戶的信息來解決此問題。 我應該將 notifu.exe 移動到我的節點 main.js 所在的目錄嗎?

我解決了。 在 Windows 10 (64bit) 上,在我的項目中,我使用了“node-notifier”,並收到了與上述類似的警告。 上述警報是一個警告,即可執行文件在創建后必須位於子文件夾中。

但是,在 Windows 10(64 位)中,“node-notifier”使用“soreToast-x64.exe”而不是“soreToast.exe”。

您可以按以下順序進行。

  1. 將 pkg 重新安裝到最新版本。

npm i -g pkg

  1. 從“\node_modules\node-notifier~”子文件夾中查找並復制“snoretoast-x64.exe”。

  2. 在生成的可執行子路徑中創建一個文件夾“notifier”並復制並粘貼“snoretoast-x64.exe”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM