yao-pkg / pkg

Package your Node.js project into an executable
https://www.npmjs.com/package/@yao-pkg/pkg
MIT License
312 stars 11 forks source link

clipboard-sys not supported #42

Closed cage1618 closed 5 months ago

cage1618 commented 5 months ago

What version of pkg are you using?

5.11.5

What version of Node.js are you using?

20.11.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?

node20

Describe the Bug

I use clipboard-sys to copy image to cilpboard, on windows, i canuth an error: Command failed with ENOENT: C:\snapshot\buddy\node_modules\clipboard-sys\dist\bin\win_clipboard.exe

Expected Behavior

no error

To Reproduce

const {clipboard} = require('clipboard-sys');

await clipboard.writeImage('C:\User\abc\a.png');

robertsLando commented 5 months ago

@cage1618 Try adding node_modules\clipboard-sys\dist\bin\win_clipboard.exe to assets

cage1618 commented 5 months ago

I was tried,no effect

cage1618 commented 5 months ago

I add node_modules/clipboard-sys/**/* to the assets

robertsLando commented 5 months ago

I think the exe should be moved to local directory before executing it, dunno if you can copy it to a temp dir and specify a custom path to the exe when running the command

cage1618 commented 5 months ago

like temp dir?

cage1618 commented 5 months ago

I copy the file to the root dir, still not work

robertsLando commented 5 months ago

No clue I'm sorry

cage1618 commented 5 months ago

my soluation: 1.use fs.readFile and fs.writeFile copy the binairy file from snapshot filesystem to real filesystem

  1. use execa or child_process.exec execuate it

note: you must have write permission of the target dir on the real filesystem.