The process.arch() method is used for getting the CPU architecture of the computer for which the compilation of current node.js process is taking place. Some of the possible values for the same are: 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 'x32', 'x64', etc.
Syntax
process.arch()
Parameters
Since it returns the architecture for the code where compilation is taking place. It does not need any input. It just returns the architecture name.
Example
Create a file with name – architecture.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the example below −
node architecture.js
architecture.js
// Node.js program to demonstrate the use of process.arch // Importing the process module const process = require('process'); // Printing the arch of given system console.log(process.arch);
Output
C:\home\node>> node architecture.js x64
Example
Let's take a look at one more example.
// Node.js program to demonstrate the use of process.arch // Importing the process module const process = require('process'); // Printing the value for given architecture switch(process.arch) { case 'x32': console.log("This is a 32-bit extended systems"); break; case 'x64': console.log("This is a 64-bit extended systems"); break; case 'arm': console.log("This is a 32-bit Advanced RISC Machine"); break; case 'arm64': console.log("This is a 64-bit Advanced RISC Machine"); break; case 'mips': console.log("This is a 32-bit Microprocessor without " + "Interlocked Pipelined Stages"); break; case 'ia32': console.log("This is a 32-bit Intel Architecture"); break; case 'ppc': console.log("This is a PowerPC Architecture."); break; case 'ppc64': console.log("This is a 64-bit PowerPC Architecture."); break; // You can add more architectures if you know... default: colsole.log("This architecture is unknown."); }
Output
C:\home\node>> node architecture.js This is a 64-bit extended systems