Skip to content

Commit db7f2c5

Browse files
committed
docs: explain how to execute binary from snapshot
1 parent 7ff82b2 commit db7f2c5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,34 @@ const child = spawn(process.execPath, [process.argv[1]], {
419419

420420
More info [here](https://github.com/yao-pkg/pkg/pull/90)
421421

422+
### Error: Cannot execute binaray from snapshot
423+
424+
Binaries must be extracted from snapshot in order to be executed. In order to do this you can use this approach:
425+
426+
```js
427+
const cp = require('child_process');
428+
const fs = require('fs');
429+
const { pipeline } = require('stream/promises');
430+
431+
let ffmpeg = require('@ffmpeg-installer/ffmpeg').path;
432+
433+
const loadPlugin = async () => {
434+
if (process.pkg) {
435+
// copy ffmpeg to the current directory
436+
const file = fs.createWriteStream('ffmpeg');
437+
await pipeline(fs.createReadStream(ffmpeg), file);
438+
439+
fs.chmodSync('ffmpeg', 0o755);
440+
console.log('ffmpeg copied to the current directory');
441+
ffmpeg = './ffmpeg';
442+
}
443+
444+
cp.execSync(ffmpeg);
445+
};
446+
447+
loadPlugin();
448+
```
449+
422450
### Error: ENOENT: no such file or directory, uv_chdir
423451

424452
This error can be caused by deleting the directory the application is

0 commit comments

Comments
 (0)