Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
562
Reaction score
805
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/
 

Latest Threads

Latest Posts

Latest Profile Posts

I've been in Fort Myers since Thursday night. I'm going home tomorrow or the next day... lol, I desperately need a good taste of homemade Japanese food. I might not be Japanese or even Asian (I'm American born and raised), but I absolutely love authentic Japanese cooking. Restaurant food doesn't do it justice.
Haven't been working on any of my projects or resources lately as I'll soon be moving to a new apartment. It's been a stressful move but I'm really looking forward to it.
//Sees it's the same price at Best Buy for a new SSD as Amazon
//Sees it's 103F outside and Best Buy is half a hour of driving.
//Orders from Amazon.
I'll wait the 2-3 days. :LZSwink:
Just a little teaser screenshot of Mountain Village...

Screenshot (364).png

Forum statistics

Threads
112,373
Messages
1,067,866
Members
146,024
Latest member
BestElfie
Top