mediasoup node js app to exe

Hello to everyone
I convert mediasoup node js app to exe .
When I run the exe the worker gives an error.
i used pkg to make exe.

 package.json
 "pkg": {
    "assets": [
      "node_modules/",
      "node_modules/**/*",
      "node_modules/mediasoup/**/*"
    ],
    "outputPath": "dist"
  }

command => pkg build/index.js --config package.json --targets node16-linux-x64
when i run the exe ,
error => spawn /snapshot/MediaServer-Ts/node_modules/mediasoup/worker/out/Release/mediasoup-worker ENOENT

do you have any idea about this issue?

It seems to say that worker file it is looking for is missing (probably wasn’t included in the package for some reason).

thanks for the answer
It shows up as added in the logs.

[debug] The file was included as asset content
/home/hd/Desktop/MediaServer-Ts/node_modules/mediasoup/worker/out/Release/mediasoup-worker
[debug] The file was included as asset content
/home/hd/Desktop/MediaServer-Ts/node_modules/mediasoup/worker/out/Release/mediasoup-worker
[debug] The file was included as asset content

As you can see in the error log, when executing the exe it cannot find mediasoup-worker due to wrong path since pkg changes it’s location. You can tell mediasoup when the binary is (see Building.md file, there is an environmental variant for that).

Other than that, this is a topic related to pkg.

1 Like

thank you for answering

yes actually the problem is
import { createWorker as createWorker } from "/home/hd/Desktop/MediaServer-Ts/node_modules/mediasoup";
this is how it works

import { createWorker as createWorker } from "mediasoup";
it doesn’t work that way
this problem only happens in mediasoup library.
I asked here in case anyone faced this problem before

MEDIASOUP_WORKER_BIN="…/node_modules/mediasoup/worker/out/Release/mediasoup-worker" ./testexe it worked like this