Nodemon will crashed with this error when the exec comman return error code 2

[Nodemon] failed to start process, possible issue with exec arguments
events.js:146
	throw err;
	^

Error: Uncaught, unspecified "error" event. (2)
	at emit (events.js:144:17)

Error code 2 is reserved for bash. Command line tools like mocha or jshint sometimes will throw error 2. When jshint or mocha executed as argument to -x in nodemon. Nodemon crash.

A simple workaround is to put exit 1 in the -x

$nodemon --e js -w ./ -d 1 -x 'mocha ./test || exit 1'

Related
Nodemon code
JSHint integration on github
Nodejs exit code