Finds the npm username of the logged in npm user.
var npmWhoami = require('npm-whoami');
npmWhoami(function(err, username) {
console.log(username);
// james.talmage
});
Required
Type: function (err, username)
Called with the npm username, or an error if it can not be found.
Optional
Type: object | string | number
If a string
, it will be treated as the registry url.
If a number
, it will be used as the timeout value.
You can pass an object hash if you need both values.
Optional
Type: string
Will use the --registry
flag to set an alternate registry url.
Optional
Type: number
Sets a maximum time to wait for a response from the server (in ms). Default is 10,000 ms.
npmWhoami({
registry: 'http://localhost:55550',
timeout: 4000
}, cb);
Same available options
as the async version.
Returns a string username, or throws if the user is not logged in.
This synchronous function is not available on v0.10.x
or earlier.
MIT © James Talmage