To understand this we will take some simple process example to print architecture, pid, platform and version of the process.
File: processexample1.js
console.log(`Process Architecture: ${process.arch}`);
console.log(`Process PID: ${process.pid}`);
console.log(`Process Platform: ${process.platform}`);
console.log(`Process Version: ${process.version}`);
Now open Node.js command prompt and run the below code:-
node processexample1.js
Now will take another process example which is used to print command line arguments. Here node is considered as the first argument, filename is considered as the second argument and actual command line arguments are considered as third, fourth, fifth and so on.
File: processexample2.js
process.argv.forEach((value, index, array) => {
console.log(`${index}: ${value}`);
});
Open Node.js command prompt and run the following code:
node processexample2.js
Node.js Process Functions
A list of commonly used Node.js process functions are given below.