4

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.

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.