vercel / pkg

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

Uncorrected packaging exe-containing library into exe. #1902

Closed 40oleg closed 1 year ago

40oleg commented 1 year ago

What version of pkg are you using?

5.7.0

What version of Node.js are you using?

16.15.1

What operating system are you using?

Windows

What CPU architecture are you using?

x86_64

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

node16-win-x64

Describe the Bug

I am using library wallpaper.js and try to pack it into executable. But when I run resulting executable, there is an error ENOENT for executable that library uses under the hood. This executable is located in node_modules. The problem that library exe-file exists inside pack, I checked it. But it can't be called for some reasons I don't understand. Just throw error ENOENT.

Expected Behavior

This must works correctly, but it doesn`t. when execFile happend program throws execption ENOENT win-wallpaper.exe. BUT, it does work if you just run it through node.js

main.js file

const {promisify} = require('util');
const path = require('path');
const childProcess = require('child_process');

const execFile = promisify(childProcess.execFile);

const binary = path.join(__dirname, 'exe/win-wallpaper.exe');
const img = path.join(__dirname, './0.png');
console.log(img)

execFile(binary, [img])
    .then(data => console.log(data))
    .catch(data => console.log(data))

pkg.json which I used for compiling

{
  "pkg": {
    "assets": [
      "assets/**/*",
      "exe/*"
    ],
    "targets": [
      "node16-win-x64"
    ]
  }
}

To Reproduce

You can use script above and run it with node and after compile it with pkg and try to run (It throws error ENOENT). Instead of win-wallpaper.exe you can use whatever executable you want.

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.