{"id":14155984,"url":"https://github.com/sindresorhus/environment","last_synced_at":"2025-04-07T05:06:58.768Z","repository":{"id":236802244,"uuid":"793180075","full_name":"sindresorhus/environment","owner":"sindresorhus","description":"Check which JavaScript environment your code is running in at runtime: browser, Node.js, Bun, etc","archived":false,"fork":false,"pushed_at":"2024-09-13T06:20:07.000Z","size":7,"stargazers_count":162,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T04:04:00.587Z","etag":null,"topics":["check-environment","node-module","npm-package","runtime-environment"],"latest_commit_sha":null,"homepage":"","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":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2024-04-28T16:48:10.000Z","updated_at":"2025-03-12T14:32:57.000Z","dependencies_parsed_at":"2024-05-15T13:07:34.076Z","dependency_job_id":"bbaf6922-0bca-4bfd-a75e-1ce6d830e261","html_url":"https://github.com/sindresorhus/environment","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"0e664a280bbbb4569458b25d175eb745a5cb4d29"},"previous_names":["sindresorhus/which-environment","sindresorhus/environment"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fenvironment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fenvironment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fenvironment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fenvironment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/environment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595333,"owners_count":20963943,"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":["check-environment","node-module","npm-package","runtime-environment"],"created_at":"2024-08-17T08:05:08.108Z","updated_at":"2025-04-07T05:06:58.748Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["others"],"sub_categories":[],"readme":"# environment\n\n\u003e Check which JavaScript environment your code is running in at runtime\n\n## Install\n\n```sh\nnpm install environment\n```\n\n## Usage\n\n```js\nimport {isBrowser, isNode} from 'environment';\n\nif (isBrowser) {\n\tconsole.log('Running in a browser!');\n}\n\nif (isNode) {\n\tconsole.log('Running in Node.js!');\n}\n```\n\n\u003e [!NOTE]\n\u003e Runtime checks should be used sparingly. Prefer [conditional package exports](https://nodejs.org/api/packages.html#conditional-exports) and [imports](https://nodejs.org/api/packages.html#subpath-imports) whenever possible.\n\n## API\n\n### `isBrowser`\n\nCheck if the code is running in a web browser environment.\n\n### `isNode`\n\nCheck if the code is running in a [Node.js](https://nodejs.org) environment.\n\n### `isBun`\n\nCheck if the code is running in a [Bun](https://bun.sh) environment.\n\n### `isDeno`\n\nCheck if the code is running in a [Deno](https://deno.com) environment.\n\n### `isElectron`\n\nCheck if the code is running in an [Electron](https://www.electronjs.org) environment.\n\n### `isJsDom`\n\nCheck if the code is running in a [jsdom](https://github.com/jsdom/jsdom) environment.\n\n### `isWebWorker`\n\nCheck if the code is running in a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API#worker_global_contexts_and_functions) environment, which could be either a dedicated worker, shared worker, or service worker.\n\n### `isDedicatedWorker`\n\nCheck if the code is running in a [Dedicated Worker](https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope) environment.\n\n### `isSharedWorker`\n\nCheck if the code is running in a [Shared Worker](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope) environment.\n\n### `isServiceWorker`\n\nCheck if the code is running in a [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope) environment.\n\n### `isMacOs`\n\nCheck if the code is running on macOS.\n\n### `isWindows`\n\nCheck if the code is running on Windows.\n\n### `isLinux`\n\nCheck if the code is running on Linux.\n\n### `isIos`\n\nCheck if the code is running on iOS.\n\n### `isAndroid`\n\nCheck if the code is running on Android.\n\n## Related\n\n- [is-in-ci](https://github.com/sindresorhus/is-in-ci) - Check if the process is running in a CI environment\n- [is64bit](https://github.com/sindresorhus/is64bit) - Check if the operating system CPU architecture is 64-bit or 32-bit\n- [is](https://github.com/sindresorhus/is) - Type check values\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fenvironment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fenvironment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fenvironment/lists"}