index.js
function checkName(name, cb) {
  request(`https://registry.npmjs.org/${name}/latest`, {}, function(err, res, msg) {
    if (err) return cb(err);

    if (typeof msg === 'string' && msg === 'Package not found') {
      cb(null, false);
      return;
    }

    if (res && res.statusCode === 404) {
      return cb(null, false);
    }

    cb(null, true);
  });
}
function checkName(name, cb) {
  request(`https://registry.npmjs.org/${name}/latest`, {}, function(err, res, msg) {
    if (err) return cb(err);

    if (typeof msg === 'string' && msg === 'Package not found') {
      cb(null, false);
      return;
    }

    if (res && res.statusCode === 404) {
      return cb(null, false);
    }

    cb(null, true);
  });
}
function checkName ( name , cb ) { request ( ` ${ name } ` , { } , function ( err , res , msg ) { if ( err ) return cb ( err ) ; if ( typeof msg === 'string' && msg === 'Package not found' ) { cb ( null , false ) ; return ; } if ( res && res . statusCode === 404 ) { return cb ( null , false ) ; } cb ( null , true ) ; } ) ; }
Check if a name exists on npm.

```js
checkName('foo', function(err, exists) {
if (err) throw err;
console.log(exists);
});
//=> true
```
@param  {String} `name` Name of module to check.
@param  {Function} `cb` Callback function
Check if a name exists on npm .