{"id":708,"url":"https://github.com/sindresorhus/username","last_synced_at":"2025-04-04T13:07:10.606Z","repository":{"id":15535503,"uuid":"18270175","full_name":"sindresorhus/username","owner":"sindresorhus","description":"Get the username of the current user","archived":false,"fork":false,"pushed_at":"2023-11-14T16:18:47.000Z","size":37,"stargazers_count":142,"open_issues_count":0,"forks_count":14,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-27T19:26:27.798Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-03-30T18:12:49.000Z","updated_at":"2025-01-28T22:18:39.000Z","dependencies_parsed_at":"2024-01-19T11:33:09.037Z","dependency_job_id":"dde3baf5-a0df-4b87-91f0-f15fca7a0b87","html_url":"https://github.com/sindresorhus/username","commit_stats":{"total_commits":54,"total_committers":9,"mean_commits":6.0,"dds":"0.18518518518518523","last_synced_commit":"81eb6d86579592969e32d798d3fd660720450d3b"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fusername","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fusername/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fusername/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fusername/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/username/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247181641,"owners_count":20897370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:29.330Z","updated_at":"2025-04-04T13:07:10.577Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","Repository","Modules","模块","Libraries"],"sub_categories":["Environment","CLI"],"readme":"# username\n\n\u003e Get the username of the current user\n\nThis module is meant for informational purposes and not for secure identification.\n\n## Install\n\n```sh\nnpm install username\n```\n\n*This package only works in Node.js, not in browsers.*\n\n## Usage\n\n```js\nimport {username} from 'username';\n\nconsole.log(await username());\n//=\u003e 'sindresorhus'\n```\n\n## API\n\nIt 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.\n\n### `username(): Promise\u003cstring | undefined\u003e`\n\nReturns the username.\n\n### `usernameSync(): string | undefined`\n\nReturns the username.\n\n## Related\n\n- [username-cli](https://github.com/sindresorhus/username-cli) - CLI for this module\n- [fullname](https://github.com/sindresorhus/fullname) - Get the fullname of the current user\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fusername","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fusername","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fusername/lists"}