or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-is-windows

Returns true if the platform is windows, works with node.js, commonjs, browser, AMD, electron, etc.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/is-windows@1.0.x

To install, run

npx @tessl/cli install tessl/npm-is-windows@1.0.0

index.mddocs/

is-windows

Returns true if the platform is Windows. This is a lightweight UMD module that works across Node.js, CommonJS, browser, AMD, Electron and other JavaScript environments. It detects Windows platform including native Windows (win32), MSYS environments (Git Bash, MSYS2), and Cygwin environments.

Package Information

  • Package Name: is-windows
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install is-windows

Core Imports

var isWindows = require('is-windows');

For ES6 imports (if transpiled):

import isWindows from 'is-windows';

Basic Usage

var isWindows = require('is-windows');

console.log(isWindows());
// => true on Windows platforms, false otherwise

// Works in all environments
if (isWindows()) {
  // Windows-specific code
  console.log('Running on Windows');
} else {
  // Non-Windows code
  console.log('Running on non-Windows platform');
}

Capabilities

Platform Detection

Detects if the current platform is Windows by checking both standard Windows detection and Windows-like environments.

/**
 * Detects if the current platform is Windows
 * @returns {boolean} true if running on Windows platform, false otherwise
 */
function isWindows() {}

Detection Logic:

  • Returns true if process.platform === 'win32' (native Windows)
  • Returns true if process.env.OSTYPE matches msys or cygwin (Windows-like environments)
  • Returns false for all other platforms

Supported Environments:

  • Node.js: CommonJS module export
  • Browser: Available as window.isWindows()
  • Web Workers: Available as self.isWindows()
  • AMD: Compatible with RequireJS and other AMD loaders
  • Electron: Works in both main and renderer processes
  • Universal: Falls back to global scope attachment

Environment-Specific Usage

Node.js / CommonJS

const isWindows = require('is-windows');

if (isWindows()) {
  require('child_process').spawn('cmd', ['/c', 'dir']);
} else {
  require('child_process').spawn('ls', ['-la']);
}

Browser

<script src="node_modules/is-windows/index.js"></script>
<script>
  if (window.isWindows()) {
    console.log('Browser is running on Windows');
  }
</script>

AMD (RequireJS)

define(['is-windows'], function(isWindows) {
  return function() {
    if (isWindows()) {
      // Windows-specific logic
    }
  };
});

ES6 Modules (with transpilation)

import isWindows from 'is-windows';

const platform = isWindows() ? 'windows' : 'other';
console.log(`Running on: ${platform}`);

Platform Coverage

The function detects the following Windows environments:

  • Windows 10/11: Standard win32 platform detection
  • Windows Server: All versions detected via win32
  • Git Bash: Detected via OSTYPE=msys
  • MSYS2: Detected via OSTYPE=msys
  • Cygwin: Detected via OSTYPE=cygwin
  • WSL: Not detected (reports as Linux, which is technically correct)

Zero Dependencies

This package has no dependencies and adds minimal overhead to your project. The entire module is self-contained in a single file with UMD (Universal Module Definition) wrapper that automatically detects and adapts to the available module system (CommonJS, AMD, or global scope), ensuring maximum compatibility across all JavaScript environments.