stackoverflow

View on StackOverflow ..

Definitely, the easiest way to do it is using username

Install:

$ npm install username

Then:

const username = require('username');

(async () => {
    console.log(await username());
	//=> 'current_username'
})();