code: function isPortTaken(port, fn) {
    const net = require('net')
    const tester = net.createServer()
      .once('error', function (err) {
        if (err.code != 'EADDRINUSE') return fn(err)
        fn(null, true)
      })
      .once('listening', function() {
        tester.once('close', function() { fn(null, false) })
          .close()
      })
      .listen(port)
  }
docs: Checks if a port is already taken by another app.
  
  Source: https://gist.github.com/timoxley/1689041
  @param port
  @param fn