vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.28k stars 1.01k forks source link

Warning Cannot include file %1 into executable - pkg error #1657

Closed frodoe7 closed 1 year ago

frodoe7 commented 2 years ago

What version of pkg are you using?

5.7.0

What version of Node.js are you using?

16.14.0

What operating system are you using?

macOS

What CPU architecture are you using?

Quad-Core Intel Core i7

What Node versions, OSs and CPU architectures are you building for?

node16-linux-x64, node16-macos-x64, node16-win-x64

Describe the Bug

Here's the output after running pkg index.js

Targets not specified. Assuming: node16-linux-x64, node16-macos-x64, node16-win-x64

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-x64.exe %2: path-to-executable/notifier/snoretoast-x64.exe

Warning Cannot include file %1 into executable. The file must be distributed with executable as %2. %1: node_modules/node-notifier/vendor/snoreToast/snoretoast-x86.exe %2: path-to-executable/notifier/snoretoast-x86.exe

Warning Cannot include file %1 into executable. The file must be distributed with executable as %2. %1: node_modules/open/xdg-open %2: path-to-executable/xdg-open

Looks there's an issue between pkg and node-notifier package https://github.com/mikaelbr/node-notifier

A similar issue https://github.com/mikaelbr/node-notifier/issues/220#issuecomment-841725820

Anyone have any ideas how to fix that?

Expected Behavior

To bundle the file correctly and show notifications from that package node-notifier

To Reproduce

Build a minimal project with node-notifier and try to run any notification

will work on the development environment, but after bundling with pkg, will fire these warnings and won't show any notifications

Devilsmaul commented 2 years ago

I got the same error with package "level": "^7.0.0"

Warning Cannot include directory %1 into executable. The directory must be distributed with executable as %2. %1: node_modules/leveldown/prebuilds %2: path-to-executable/prebuilds Warning Cannot include directory %1 into executable. The directory must be distributed with executable as %2. %1: node_modules/leveldown/prebuilds %2: path-to-executable/prebuilds

Devilsmaul commented 2 years ago

reading the output more carefully i was able to fix this issue. i had to copy the prebuilds from %1: node_modules/leveldown/prebuilds into my executable directory in the folder prebuilds

image

AliSawari commented 2 years ago

I have the same issue, also trying to use node-notifier with pkg OS: Windows 10 64bit Node: 16.15.1 Output

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-x64.exe
  %2: path-to-executable/notifier/snoretoast-x64.exe
> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  %1: node_modules\node-notifier\vendor\snoreToast\snoretoast-x86.exe
  %2: path-to-executable/notifier/snoretoast-x86.exe

apparently #1021. didn't fix this issue

mazero commented 2 years ago

I have the same error.

Cannot include file %1 into executable. The file must be distributed with executable as %2. %1: node_modules\open\xdg-open %2: path-to-executable/xdg-open

Any ideas ? I try to copy/paste the module in the exectuable folder... but nothing :/

MariuzM commented 2 years ago

For me same issue:

> pkg@5.8.0
> Targets not specified. Assuming:
  node18-linux-arm64, node18-macos-arm64, node18-win-arm64
> Warning Cannot include directory %1 into executable.
  The directory must be distributed with executable as %2.
  %1: ../node_modules/puppeteer/.local-chromium
  %2: path-to-executable/puppeteer
> Warning Failed to make bytecode node18-arm64 for file /snapshot/<PROJECT>/build/app.js
> Warning Failed to make bytecode node18-arm64 for file /snapshot/<PROJECT>/build/app.js
> Warning Failed to make bytecode node18-arm64 for file C:\snapshot\<PROJECT>\build\app.js
Devilsmaul commented 1 year ago

@MariuzM have you tried to copy /node_modules/puppeteer/.local-chromium into path-to-executable/puppeteer ?

wlc015f commented 1 year ago

i've got same error with sharp, and find no solution

can anyone have the solution? got the same issue with sharp.

Warning Cannot include directory %1 into executable. The directory must be distributed with executable as %2. %1: node_modules\sharp\build\Release %2: path-to-executable/sharp/build/Release

rajajwaliya commented 1 year ago

it is resolved. I am using caxa npm.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] commented 1 year ago

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

good1uck commented 1 year ago

image

good1uck commented 1 year ago

Try above