
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Get the username of the current user
This module is meant for informational purposes and not for secure identification.
npm install username
This package only works in Node.js, not in browsers.
import {username} from 'username';
console.log(await username());
//=> 'sindresorhus'
It first tries to get the username from the SUDO_USER LOGNAME USER LNAME USERNAME environment variables. Then falls back to $ id -un on macOS / Linux and $ whoami on Windows, in the rare case none of the environment variables are set. The result is cached.
username(): Promise<string | undefined>Returns the username.
usernameSync(): string | undefinedReturns the username.
The 'user-info' package is another alternative that provides detailed information about the current user, such as username, UID, GID, and shell. It is more comprehensive than 'username', which is specifically designed to fetch only the username.
FAQs
Get the username of the current user
The npm package username receives a total of 573,219 weekly downloads. As such, username popularity was classified as popular.
We found that username demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.