title: AngularJS app server won't start with npm start
body: <p>I was working on the AngularJS <code>angular-phonecat</code> tutorial on my MacBook, yesterday. It worked fine. (although <code>npm start</code> and <code>npm test</code> both required <code>sudo</code> to actually work, which is strange)</p>
  
  <p>Today, I cloned the original repo onto my MacBookPro, ran <code>npm install</code>, and tried starting up with <code>npm start</code>, and I get errors:</p>
  
  <pre><code>$ npm start
  
  ... other scripts running ...
  
  &gt; http-server ./app -a localhost -p 8000 -c-1
  
  events.js:173
        throw er; // Unhandled 'error' event
        ^
  
  Error: getaddrinfo ENOTFOUND localhost
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:26)
  Emitted 'error' event at:
      at GetAddrInfoReqWrap.doListen [as callback] (net.js:1440:12)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:17)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! angular-phonecat@0.0.0 start: `http-server ./app -a localhost -p 8000 -c-1`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the angular-phonecat@0.0.0 start script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /Users/TuzMacbookPro2017/.npm/_logs/2019-05-23T17_54_25_562Z-debug.log
  </code></pre>
  
  <p>Running just the last line of the script gives a similar though less verbose error:</p>
  
  <pre><code>$ http-server ./app -a localhost -p 8000 -c-1
  events.js:173
        throw er; // Unhandled 'error' event
        ^
  
  Error: getaddrinfo ENOTFOUND localhost
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:26)
  Emitted 'error' event at:
      at GetAddrInfoReqWrap.doListen [as callback] (net.js:1440:12)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:17)
  </code></pre>
  
  <p>To add insult to injury, when I run <code>sudo npm start</code> in the copy of the tutorial app on the computer I was working on yesterday, and then visit the url <code>localhost:8000</code> I get a <code>400</code> error. I can't image what would have changed since yesterday! <code>sudo npm test</code> launches the Karma tests without any problems on both computers (though the MacBook Pro doesn't require <code>sudo</code>).</p>
  
  <p>Currently running npm 6.4.1 on both computers. The MacBook is on node 10.15.3, and the MacBookPro is on node 11.12.0</p>
  
  <p>Even worse: I just now downloaded a new clone of the repo (straight from the angular website) and now the MacBook is giving this error when running <code>npm start</code>, with or without <code>sudo</code>:</p>
  
  <pre><code>&gt; http-server ./app -a localhost -p 8000 -c-1
  
  events.js:174
        throw er; // Unhandled 'error' event
        ^
  
  Error: listen EADDRINUSE: address already in use 127.0.0.1:8000
      at Server.setupListenHandle [as _listen2] (net.js:1270:14)
      at listenInCluster (net.js:1318:12)
      at GetAddrInfoReqWrap.doListen [as callback] (net.js:1451:7)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10)
  Emitted 'error' event at:
      at emitErrorNT (net.js:1297:8)
      at process._tickCallback (internal/process/next_tick.js:63:19)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! angular-phonecat@0.0.0 start: `http-server ./app -a localhost -p 8000 -c-1`
  npm ERR! Exit status 1
  </code></pre>
  
  <p>What is wrong?</p>