2

I am using npm run watch to wath the react typescript project file changes and rebuild the source code, but sometimes the watch process will exit automatically when compile failed, I was wonder is it possible to minitor the npm process in macOS, when the npm run watch command exit, start the command automatically.

1 Answer 1

3

No need for an out-of-band monitoring solution; put the command in a loop to run infinitely.

In zsh or bash,

while true; do npm run watch; sleep 1; done

If npm run watch exits, it will sleep 1s, then run the command again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .