
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
environment
Advanced tools
Check which JavaScript environment your code is running in at runtime: browser, Node.js, Bun, etc
Check which JavaScript environment your code is running in at runtime
npm install environment
import {isBrowser, isNode} from 'environment';
if (isBrowser) {
console.log('Running in a browser!');
}
if (isNode) {
console.log('Running in Node.js!');
}
[!NOTE] Runtime checks should be used sparingly. Prefer conditional package exports and imports whenever possible.
isBrowser
Check if the code is running in a web browser environment.
isNode
Check if the code is running in a Node.js environment.
isBun
Check if the code is running in a Bun environment.
isDeno
Check if the code is running in a Deno environment.
isElectron
Check if the code is running in an Electron environment.
isJsDom
Check if the code is running in a jsdom environment.
isWebWorker
Check if the code is running in a Web Worker environment, which could be either a dedicated worker, shared worker, or service worker.
isDedicatedWorker
Check if the code is running in a Dedicated Worker environment.
isSharedWorker
Check if the code is running in a Shared Worker environment.
isServiceWorker
Check if the code is running in a Service Worker environment.
isMacOs
Check if the code is running on macOS.
isWindows
Check if the code is running on Windows.
isLinux
Check if the code is running on Linux.
isIos
Check if the code is running on iOS.
isAndroid
Check if the code is running on Android.
FAQs
Check which JavaScript environment your code is running in at runtime: browser, Node.js, Bun, etc
We found that environment demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.