Nodejs, Find 32 or 64-bit in windows/Linux

We sometimes need to know whether NodeJS is installed on the 32-bit or `64-bit version on Windows, Linux, Mac, and Ubuntu PCs.

32-bit is 4 bytes of data, 64 bit is 8 bytes of data memory allocated, so Each machine has a different architecture to store and process the data.

Nodejs offers multiple ways to know it.

  • using REPL
  • Javascript programming

You can also check other posts on npm command deprecate option is deprecated

Node REPL to Check 32-bit or 64-bit

REPL is a console for NODEJS to execute commands. It is like a windows command prompt or Linux shell prompt. It comes with a default installation of the Nodejs platform.

There are two ways to know the bit version.

First way, Type node in the command prompt to get into REPL mode. You will get REPL mode in interactive mode.

Nodejs provides an OS module to get current installed machine information. arch() function returns current system CPU information, return values are x32, x64.

> require('os').arch()

The second way,
using a global process object, get the current node process information. It is not required to import the module as it is a global object.


And it outputs a lot of processes metadata environment information. One of the properties is PROCESSOR_ARCHITECTURE and its value tells about 64bit or not.

Platform: 'MCD',
platformcode: 'KV',
PROCESSOR_IDENTIFIER: 'Intel64 Family 6 Model 78 Stepping 3, GenuineIntel',

or The third way, process.arch gives Nodejs process global objects arch gives.

node -p "process.arch"

These returns are a 32 for 32-bit machines or x64 for 64bit machines.

Find 32-bit or 64-bit using JavaScript code

First, using the OS inbuilt module, import it using the required keyword OS has an arch() method that returns process architecture information.

const os = require("os");

The second way is using the process global object with the arch property.


Finally, using the process.envreturns process meta information

console.log(process.env.PROCESSOR_ARCHITECTURE); //returns AMD64 or IA32


To summarize, Nodejs offers many ways to get process current machine information, either REPL command or Javascript code.