I am calling a NodeJS file like this in a shell script:
$ node process.js
$ let "errors |= $?"
I want to see if the process.js file returned any errors. How do I return a value inside process.js file so that I can capture it in my shell script.
You can set the exitCode (and let the node process die naturally):
process.exitCode = 1
Or you can force-kill it:
process.exit(1)
in both cases it will return 1 as the exit code.
https://nodejs.org/api/process.html#process_process_exit_code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With