First, similar questions, no answers:
Node.js child_process.spawn() fail to run executable file
node.js child_process.spawn ENOENT error - only under supervisord
I have an executable file with .linux
extension. It is http server.
service.linux
I can run it like this:
$ ./service.linux
2018/01/11 18:32:56 listening on port 8080
But since it is not a command, I cannot start it as a spawned process:
let cp = spawn('service.linux', [], { cwd: __dirname });
The errors I get is:
service.linux: command not found
ERROR: Error: spawn service.linux ENOENT
How can I run it as a command? Or should I use some other command to run it, like:
$ start service.linux
UPD:
$ file service.linux
service.linux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
UPD:
It needs absolute path:
const path = require('path');
let cp = spawn(path.resolve(__dirname, `service.linux`), [], { cwd: __dirname });