Skip to content

Commit

Permalink
docs: explain how to execute binary from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Sep 24, 2024
1 parent 7ff82b2 commit db7f2c5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,34 @@ const child = spawn(process.execPath, [process.argv[1]], {

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

### Error: Cannot execute binaray from snapshot

Binaries must be extracted from snapshot in order to be executed. In order to do this you can use this approach:

```js
const cp = require('child_process');
const fs = require('fs');
const { pipeline } = require('stream/promises');

let ffmpeg = require('@ffmpeg-installer/ffmpeg').path;

const loadPlugin = async () => {
if (process.pkg) {
// copy ffmpeg to the current directory
const file = fs.createWriteStream('ffmpeg');
await pipeline(fs.createReadStream(ffmpeg), file);

fs.chmodSync('ffmpeg', 0o755);
console.log('ffmpeg copied to the current directory');
ffmpeg = './ffmpeg';
}

cp.execSync(ffmpeg);
};

loadPlugin();
```

### Error: ENOENT: no such file or directory, uv_chdir

This error can be caused by deleting the directory the application is
Expand Down

0 comments on commit db7f2c5

Please sign in to comment.