Node.js Process

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
794
First Language
English
Primarily Uses
RMMV
Introduction
"process" is one of the most important global properties in the Node.js process. The process contains information on the context that Node.js is running your script or application in. Now, let's get into detail; we'll be discussing what process is and important properties plus methods.

What Is Process?
The "process" is the context your JavaScript file is running in when Node.js is used on a script or project. At that moment, Node.js spawns a process that contains information on the shell (command prompt)), directory (path), arguments passed to Node.js and more. In essence, it's a global that provides information and control over the current Node.js process. And because it provides such information, let's discuss what those important properties are.

Important Process Properties
The "process" object contains these helpful properties: stdin, stdout, stderr, env, arch, and argv. It also has these helpful methods: chdir, cwd, exit, and kill. Lastly, "process" is an instance of the EventEmitter class, giving it helpful events the developer can listen to. However, we will only be discussing the properties and methods; let's start with the properties.

Properties
The properties stdin, stdout, and stderr control input, output, and error output in the Node.js process respectively. Each one is a stream that can be manipulated by the developer. The arch property tells you what the processor architecture is. The argv property lists the command line arguments passed to the Node.js process. Finally, env lists the environment properties associated with the current process such as shell, user, path, editor, and more. Now, with properties done, let's talk methods.

Methods
The important methods to know are chdir, cwd, exit, and kill. The chdir method changes the current directory; cwd displays the current working directory. The exit method exits the process, stopping the program. Finally, the kill method can kill any running process given a pid (process id), which can be obtained using another method outside the scope of this post.

Now, with that said, I hope this post along with all the other Node.js posts were helpful to you in learning the basic modules in Node.js. This is the end of Node.js basic. I enjoyed learning the modules over the course of the week and I hope you did too!

For More Information:

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

https://nodejs.org/dist/latest-v8.x/docs/api/
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top