Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't package with pkg module #220

Closed
EasonWang01 opened this issue Feb 9, 2018 · 11 comments
Closed

Can't package with pkg module #220

EasonWang01 opened this issue Feb 9, 2018 · 11 comments

Comments

@EasonWang01
Copy link

It will result then following

> Warning Cannot include file %1 into executable.
  The file must be distributed with executable as %2.
  ..\node_modules\node-notifier\vendor\notifu\notifu.exe
  path-to-executable/notifier/notifu.exe

OS:windows 10

@stevenwhitespacesystems
Copy link

stevenwhitespacesystems commented Oct 1, 2018

Not sure for Windows as I haven't got around to it yet but you usually have to copy that .exe file to the folder where your pkg executable is built.

i.e. copy notifu.exe to path-to-executable/notifier/notifu.exe

For any Mac user who got here, it was slightly different and PKG wasn't totally clear.

> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
node_modules/node-notifier/vendor/terminal-notifier.app/Contents/MacOS/terminal-notifier
path-to-executable/notifier/terminal-notifier

You copy the terminal-notifier executable to the location like it states but you also need to copy the following files to the same location

- node_modules/node-notifier/vendor/terminal-notifier.app/Contents/Info.plist
- node_modules/node-notifier/vendor/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib

So in the end you should have the following structure at your build folder.

- path-to-executable/app
- path-to-executable/notifier/terminal-notifier
- path-to-executable/notifier/Info.plist
- path-to-executable/notifier/MainMenu.nib

Doing the above worked for me and executed the notification from the built pkg file.

@mikaelbr
Copy link
Owner

Thanks! Added this issue to the readme

@normen
Copy link

normen commented Jan 30, 2020

This MacOS workaround doesn't seem to work (anymore). I copy the terminal-notifier executable, Info.plist and MainMenu.nib to path-to-executable/notifier/* but my own executable created by pkg doesn't seem to be able to find them.

There is no notification issued and no error message appearing when running my pkg-created executable, when running the application using "node index.js" notifications are appearing.

OS: MacOS 10.14.6
Node: 12.41.1

@PabloWestphalen
Copy link

windows 10 also doesn't seem to work

@nicam
Copy link

nicam commented Dec 20, 2020

@normen I found a workaround:

You need to copy the necessary files into the path-to-executable dir, in my base bin/

cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib bin/notifier
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Info.plist bin/notifier
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier bin/notifier

Then you need to create your own notifier, using customPath:

const notifier = new NotificationCenter({ customPath: path.resolve() + '/notifier/terminal-notifier', });

@GerkinDev
Copy link

GerkinDev commented Jan 3, 2021

For Windows 10 users (@PabloWestphalen, @EasonWang01), pkg is actually misconfigured. I've just sent a PR to fix this: vercel/pkg#1021.

@SrBrahma
Copy link

SrBrahma commented May 15, 2021

@GerkinDev i still have the

errors

> 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/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

/bin/sh: 1: [...]/node_modules/pkg/node_modules/.bin/prebuild-install: not found
/bin/sh: 1: [...]/node_modules/pkg/node_modules/.bin/prebuild-install: not found
/bin/sh: 1: [...]/node_modules/pkg/node_modules/.bin/prebuild-install: not found

Do someone know how to get it working for windows at least?

@Asteroid77
Copy link

Asteroid77 commented Jul 21, 2021

@GerkinDev i still have the

errors
Do someone know how to get it working for windows at least?

Hi, i have resolved it finally.
Maybe will be helpful for you:)
First i used pkg -t win package.json -d to open the debug mode in order to notice anything wrong.
The result of debug mode showed that:

(function (exports, require, module, __filename, __dirname) { import notifier from 'node-notifier';
                                                              ^^^^^^
SyntaxError: Cannot use import statement outside a module
    at new Script (vm.js:89:7)
    at Socket.<anonymous> ([eval]:18:19)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
> Warning Failed to make bytecode node12-x64 for file C:\snapshot\test\test.js

The problem is related to the ES6 module and i tried to complie my entry by babel :

babel test.js -d dist --presets es2015 --copy-files

and then use pkg to handle the file compiled by babel :

pkg -t win "fileComplied" -d

it works fine now

you should copy notifu.exe,notifu64.exe ,snoretoast-x86.exe,snoretoast-x64.exe,terminal-notifier to path-to-executable/notifier/

@Mike-Van
Copy link

Mike-Van commented Jul 9, 2022

@normen I found a workaround:

You need to copy the necessary files into the path-to-executable dir, in my base bin/

cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib bin/notifier
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Info.plist bin/notifier
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier bin/notifier

Then you need to create your own notifier, using customPath:

const notifier = new NotificationCenter({ customPath: path.resolve() + '/notifier/terminal-notifier', });

this answers also works for me

@kulek1
Copy link

kulek1 commented Oct 5, 2022

@normen I found a workaround:

You need to copy the necessary files into the path-to-executable dir, in my base bin/

cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib bin/notifier
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Info.plist bin/notifier
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier bin/notifier

Then you need to create your own notifier, using customPath:

const notifier = new NotificationCenter({ customPath: path.resolve() + '/notifier/terminal-notifier', });

Thanks. It works but with small caveats in my case:

  1. bin/notifier needs to be a directory so cp command should have / at the end of bin/notifier like this:
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Info.plist bin/notifier/
cp node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier bin/notifier/
  1. I have my production build in bin directory so path.resolve() wasn't resolving a proper path because it was pointing to $HOME. To fix that, I used process.execPath like this:
{
  customPath: path.join(
    process.execPath,
    '../',
    'notifier/terminal-notifier',
  ),
}

I spent some time trying to figure out why it doesn't work for me so I hope I'll save you guys a few hours of debugging.

@jmw11x
Copy link

jmw11x commented Jun 6, 2023

None of the above solutions are working anymore. See my below file structure. Where am I going wrong? pgk . does not work either.

Screen Shot 2023-06-06 at 5 03 58 PM
Screen Shot 2023-06-06 at 5 04 09 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

13 participants