title: Node UnhandledPromiseRejectionWarning
body: <p>I have a problem with my npm package like this question but I can't figure out how to solve</p>
  
  <p><a href="https://stackoverflow.com/questions/40500490/what-is-unhandled-promise-rejection">What is Unhandled Promise Rejection</a></p>
  
  <p>This is my index.js:</p>
  
  <pre><code>'use strict';
  var got = require('got');
  var registryUrl = require('registry-url');
  var Promise = require('pinkie-promise');
  
  module.exports = function (name) {
      if (typeof name !== 'string') {
          return Promise.reject(new Error('username required'));
      }
  
      return got.head(registryUrl + name.toLowerCase())
          .then(function (res) {
              return 'test';
          })
          .catch(function (err) {
              if (err.statusCode === 404) {
                  err.message = 'Package doesn\'t exist';
              }
  
              throw err;
          });
  };
  </code></pre>
  
  <p>this is my cli.js</p>
  
  <pre><code>#!/usr/bin/env node
  'use strict';
  var pkg = require('./package.json');
  var info = require('./');
  var argv = process.argv.slice(2);
  var input = argv[0];
  
  function help() {
      console.log(pkg.description);
      console.log('');
      console.log('Usage');
      console.log('  $ package-info &lt;package-name&gt;');
      console.log('');
      console.log('Example');
      console.log('  $ package-info pageres');
  }
  
  if (!input || argv.indexOf('--help') !== -1) {
      help();
      return;
  }
  
  if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
      console.log(pkg.version);
      return;
  }
  
  info(input, function (err, version) {
      if (err) {
          console.error(err);
          process.exit(1);
          return;
      }
  
      console.log(version);
  });
  </code></pre>
  
  <p>If I try to install locally:</p>
  
  <pre><code>npm install . -g
  npm link
  </code></pre>
  
  <p>Then i change directory and install:</p>
  
  <pre><code>cd ../otherDir
  npm install ../my-package
  </code></pre>
  
  <p>And Launch it</p>
  
  <pre><code>my-package somePackage
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>(node:2145) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RequestError: getaddrinfo ENOTFOUND function function:80
  </code></pre>
  
  <p>How can I solve It?</p>