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 Profile Posts

I've been working on something on and off for a few years now, and I've been reluctant to share any details on the project before I had anything playable because I did not want to generate hype only for the project to go back on hiatus. That being said I believe what I'm working on is very unique and pushes the boundaries of what RPG Maker projects can be. Bold claims, I know but just wait.
Happy Mother's Day to all the moms :)
Create Anime Art w/ AI, Tall Sprites with Aurora, Customize Variable Display | RPG Maker News #34

[My favorite slow moving track I've made so far]
dd_airport2.jpgdd_combat.jpg
dd_town.jpg
I did an experiment to try to solve the art style problem between RTP and 3D models.
But, it feels this grimdark world is going to end even faster. :kaoswt2:

Forum statistics

Threads
111,193
Messages
1,059,172
Members
144,440
Latest member
Kono
Top