Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

cpu-arch

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpu-arch

Detect CPU architecture (handles WoW64, Rosetta 2, ARM64)

latest
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
71
36.54%
Maintainers
1
Weekly downloads
 
Created
Source

cpu-arch

Detect CPU architecture (not process architecture).

Handles emulation scenarios where process.arch returns the wrong value:

  • Windows WoW64: 32-bit Node on 64-bit Windows → returns x64
  • macOS Rosetta 2: x64 Node on Apple Silicon → returns arm64
  • Windows ARM64: Any Node on ARM Windows → returns arm64

Installation

npm install cpu-arch

Usage

const cpuArch = require('cpu-arch');

console.log(cpuArch());
// => 'x64', 'arm64', 'ia32', 'arm', etc.

Why Not process.arch?

process.arch returns the architecture of the Node.js binary, not the CPU:

Scenarioprocess.archcpuArch()
32-bit Node on 64-bit Windowsia32x64
x64 Node on Apple Silicon (Rosetta)x64arm64
Native arm64 Node on Apple Siliconarm64arm64

This matters when selecting native binaries (e.g., @swc/core, Node.js downloads).

Return Values

ValueDescription
x6464-bit Intel/AMD
arm6464-bit ARM (Apple Silicon, ARM64 Windows/Linux)
ia3232-bit Intel/AMD
arm32-bit ARM
ia64Intel Itanium
OtherRaw uname -m output (ppc64, s390x, etc.)

Platform Detection Methods

PlatformMethod
WindowsPROCESSOR_ARCHITEW6432 / PROCESSOR_ARCHITECTURE env vars
macOSsysctl -in sysctl.proc_translated for Rosetta detection
Linuxuname -m

License

MIT

Keywords

cpu

FAQs

Package last updated on 26 Dec 2025

Did you know?

Socket

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.

Install

Related posts