how to determine whether I have 64bit or 32 bit node executable installed?
Asked Answered
H

8

125

On my windows pc I have nodejs installed. I would like to determine whether it is 64 bit or 32 bit. How can one determine that? I executed

node --help

but that does not seem to have any option to give me the desired information.

Henotheism answered 25/7, 2014 at 13:18 Comment(1)
coderwall.com/p/0eds7q Not sure if it helps as it just points out the OS arch.Trixy
C
183

Run this from the command line:

node -p "process.arch"

It will return 'arm', 'arm64', 'ia32', 'mips','mipsel', 'ppc', 'ppc64', 's390', 's390x', or 'x64'.

https://nodejs.org/api/process.html#process_process_arch

Cordy answered 26/5, 2016 at 16:4 Comment(4)
is arm 32 or 64? See hereVillus
There is also an arm64 so probably 32-bit. I will update the answer.Cordy
'x32' is not a possible value from the documentation you linked: 'arm', 'arm64', 'ia32', 'mips','mipsel', 'ppc', 'ppc64', 's390', 's390x', and 'x64' are the possible values.Spumescent
They have changed the list since I posted that. I will correct the answer though. web.archive.org/web/20210319060631/https://nodejs.org/api/…Cordy
Q
68

If node is installed and executable you can simply run

c:\> node -p "process"    

and you should see the content of the process variable formatted. There the keys arch and platform indicates your operating system. In the example below it's an Windows 7 x64

{
    title : 'Administrator: C:\\Windows\\System32\\cmd.exe - node  ',
    version : 'v0.10.36',
    moduleLoadList :
    [   'Binding evals',
        ...
        'Binding signal_wrap',
        'NativeModule string_decoder'],
    versions : {
        http_parser : '1.0',
        node : '0.10.36',
        v8 : '3.14.5.9',
        ares : '1.9.0-DEV',
        uv : '0.10.30',
        zlib : '1.2.8',
        modules : '11',
        openssl : '1.0.1l'
    },
    arch : 'x64',
    platform : 'win32',
    argv : ['node'],
    execArgv : [],
    env : {
        ALLUSERSPROFILE : 'C:\\ProgramData',
        HOMEDRIVE : 'C:',
        JAVA_HOME : 'C:\\Program Files\\Java\\jdk1.8.0_05',
        NODEJS : 'C:\\Program Files (x86)\\nodejs\\',
        NUMBER_OF_PROCESSORS : '4',
        OS : 'Windows_NT',
        Path : 'C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;',
        PATHEXT : '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY',
        PROCESSOR_ARCHITECTURE : 'AMD64',
        PROCESSOR_IDENTIFIER : 'Intel64 Family 6 Model 42 Stepping 7, GenuineIntel',
        PROCESSOR_LEVEL : '6',
        PROCESSOR_REVISION : '2a07',
        ProgramData : 'C:\\ProgramData',
        ProgramFiles : 'C:\\Program Files', 
        'ProgramFiles(x86)' : 'C:\\Program Files (x86)',
        ProgramW6432 : 'C:\\Program Files',
        PROMPT : '$P$G',
        PUBLIC : 'C:\\Users\\Public',
        PYTHON : 'C:\\Python34',
        SESSIONNAME : 'Console',
        SystemDrive : 'C:',
        SystemRoot : 'C:\\Windows',
        windir : 'C:\\Windows',
        windows_tracing_flags : '3'
    },
    features : {
        ...
    },
    config : {
        ...
    }
}
Quench answered 4/3, 2015 at 9:23 Comment(4)
Great job, doesn't use require ('os');Hyperbaton
What does platform say? Doesn't arch: x64, platform: win32 say that you are running 32 bit node in 64 bit processor?Halmahera
@Krumia: Well, "win32" often refers to the API that Windows NT introduced (and Windows 9x later implemented [a subset of]) under that name for 32-bit programs. When MS later adapted the API to support both 32-bit and 64-bit programs, this naturally resulted in the original name "win32" becoming somewhat confusing, as now people sometimes use it to refer specifically to the 32-bit variant of the API or to the i386 ABI specifically; consequently, referring to this API as "win32" has gone somewhat out of fashion. It is, however, still used even for the 64-bit version of the API.Flanigan
@Krumia: The point of all that being: very likely the win32 does not indicate anything about what instruction set node.js is built for. Furthermore, it is likely that the x64 indicates that this is in fact a 64-bit build. (Either way, it's sure to be a 64-bit OS, though, since you can't run x64-binaries on a 32-bit OS.)Flanigan
D
36

If it's on Windows OS, just go an old-school way.. by using Windows Task Manager.

Here is my attempt:-

Simply run node from command prompt.

C:\> node

This will put node into REPL mode (indicated by > symbol). Now open Task Manager (Ctrl+Shift+Esc) to see node.exe process details. Mine is on Windows 10 64-bit with node 32-bit installed. Make sure you enable 'Platform' column to see 32-bit/64-bit information.

enter image description here

Diarist answered 12/8, 2015 at 15:43 Comment(2)
as of windows 10 this seems to be missing.Nuriel
@MeirionHughes nope, you need to specifically add this column to the view. Right-click any column and select Select columnsColander
S
23

in mac

$ node
 > require('os').arch()

in windows

c:\> node
> require('os').arch()
Selective answered 4/3, 2015 at 11:33 Comment(3)
That gives OS architecture, not node'sFabulist
I tested on Windows 10 64bit with node.js 6.4.0 32bit and it returned ia32, so it is not the OS architectureWoolson
@Fabulist The os.arch() method returns a string identifying the operating system CPU architecture for which the Node.js binary was compiled. source: nodejs.org/api/os.html#os_os_archGhostwrite
C
4

This likely doesn't directly solve your problem, as I don't know the best way to get the same behavior on Windows, but using the file command on a Unix or Linux system will tell you the processor architecture of an executable:

$ file `which node`
/usr/local/bin/node: Mach-O 64-bit executable x86_64

If you have Cygwin installed, I'm pretty sure that it provides a file command, or else you could check online for similar programs that work on Windows.

Congratulate answered 25/7, 2014 at 13:35 Comment(1)
Using the file command from GnuWin32, I get PE32+ executable for MS Windows (console) Mono/.Net assembly for 64-bit programs, and PE32 executable for MS Windows (console) Intel 80386 32-bit for 32-bit programsChiromancy
F
4

Well the way I am suggesting is not at all a good way . You can go over to C: then go to Program Files and search nodejs folder there . If it is found then you are running 64 bit version else check on Program Files (x86) . If it is found there then you are running 32 bit version.

Farias answered 10/2, 2015 at 9:33 Comment(1)
The node js could have been installed on the system sometime in the past at a custom location. In that case, this isnt the solution at all.Headland
H
1

Just start node interpreter by running node. then in that, process.env gives a json with all the information you require. My try has a PROCESSOR_ARCHITECTURE: 'AMD64' entry in that.

I also find

ProgramFiles: 'C:\\Program Files', 'ProgramFiles(x86)': 'C:\\Program Files (x86)' ProgramW6432: 'C:\\Program Files'

Harmon answered 19/2, 2015 at 9:7 Comment(1)
AFAIK this just tells you what your processor is capable of; if the value is AMD64, it can still run 32-bit programs.Chiromancy
A
0

Enter the node REPL using the 'node' command.

The prompt will change to >

Then use the following to get the desired info-

  1. require('process').arch ==> this will give the node architecture version.
  2. require('process').platform ==> this will give the architecture of the compilation platform
  3. require('process').release and require('process').release.libUrl ==> also gives information about the version and achitecture
  4. require('process').config.variables.host_arch ==> this will also give the node architecture version.
Australasia answered 2/5, 2020 at 21:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.