Query npm error state in bat file

Viewed 2979

We're currently moving the build of our UI projects (3 in total) to Grunt. To ease the transition I'd like to provide a bat file that will run npm install for each project, however I'd like to know if something went wrong when issuing this command. It's merely sugar coating that I'm after, I know npm echoes errors out, but I'd like some easier messages for the members on my team that are not familiar with npm and node.

Is there a way to check whether npm has run into an error and to subsequently halt the bat file? For example, if node is not installed, I simply check for %ERRORLEVEL% to be 1. If this is the case, I echo out some instructions and exit the execution. The problem I'm having is that %ERRORLEVEL% is not set to 1 when an error occurs during a npm install.

Any help appreciated!

2 Answers
Related