title: Act on errors in NPM commands run from PowerShell
body: <p>I have an NPM command that I am running from PowerShell:</p>
  
  <pre><code>npm install process-migrator -g 
  process-migrator 
  </code></pre>
  
  <p>This command returns an error when its not configured properly, but I cant seam to pick it up in PowerShell.</p>
  
  <pre><code>[ERROR] [2018-09-25T15:30:30.610Z] Cannot find configuration file 'configuration.json'
  [INFORMATION] [2018-09-25T15:30:30.615Z] Generated configuration file as 'configuration.json', please fill in required information and retry.
  </code></pre>
  
  <p><strong>Is there some way to get the error?</strong></p>
  
  <p>I have tried:</p>
  
  <pre><code>if($?) {            
     Write-Host "Process-Migrator completed sucessfully." $LASTEXITCODE           
  } else {   
     Write-VstsTaskError "Process-Migrator FAILED " $LASTEXITCODE -ErrCode $LASTEXITCODE
  } 
  Process-Migrator completed sucessfully. 1
  </code></pre>
  
  <p>But $? is returning true and $LASTEXITCODE is a 1.</p>