Issue using child_process.execFileSync in node.js

I have an executable i’d like to use (a custom build of youtube-dl) so I place it in the project folder.
I did chmod it as another response suggested but I still get this response using execFileSync():

Error: spawnSync youtube-dl ENOENT
    at Object.spawnSync (internal/child_process.js:990:20)
    at spawnSync (child_process.js:601:24)
    at Object.execFileSync (child_process.js:629:13)
    at (/app/index.js:17:20)
    at Layer.handle [as handle_request] (/rbd/pnpm-volume/bc82a066-d4c6-4871-b7a5-621046d4f733/node_modules/
    at next (/rbd/pnpm-volume/bc82a066-d4c6-4871-b7a5-621046d4f733/node_modules/
    at Route.dispatch (/rbd/pnpm-volume/bc82a066-d4c6-4871-b7a5-621046d4f733/node_modules/
    at Layer.handle [as handle_request] (/rbd/pnpm-volume/bc82a066-d4c6-4871-b7a5-621046d4f733/node_modules/
    at /rbd/pnpm-volume/bc82a066-d4c6-4871-b7a5-621046d4f733/node_modules/
    at Function.process_params (/rbd/pnpm-volume/bc82a066-d4c6-4871-b7a5-621046d4f733/node_modules/

Help would be appreciated. Thank you

This means no entity found, or file not exist. What is the code like?



It will need to match wherever your file is, for example /app/myfile.mp4

actually, i pass as an argument to an executable called ‘youtube-dl’, which i assume it’s throwing the ENOENT at despite it being in the same directory and chmodded. (see above screenshot)

This looks like it could be similar to an issue I just recently ran into with PNPM not being able to see things in the app directory (I was also getting ENOENT errors).

Have you tried switching your project from PNPM to NPM (running the enable-npm command in the terminal)?

I just tried this and it did not work. I’m beginning to wonder if its an issue with the code or containers in general because I also get this issue on Heroku.

Try using a full path like /app/youtube-dl or wherever you have put the executable.

Changed the path to './youtube-dl' (defining the directory using the ./) and it works now! Thank you!

1 Like