Nodejs Learning Three Process objects

Source: Internet
Author: User

Rocess object, I'm talking about an object. This object contains a lot of methods and properties, and it opens a door to node. js to let our team node. js know more.

Do you know the version of node. js installed?

Do you know if your node is installed on the platform above?

Do you know the absolute path of your node executable file?

Do you want to get your ENV environment variable content?

The information you enter above can be more specific, such as Console.log (Process.env.OS).

Do you want the arguments on the command line?

OK, let's write a JS. Name Process.js

Run it on the command line:

We succeeded in getting the arguments on the command line, and for PROCESS.ARGV, the first parameter it gets is always node,

The second parameter is the path to the file, which is the parameter passed to our script starting with the third argument.

The process module provides a lot of properties and methods, such as it can return the program's return code process.exit (1), which can be used in its own function; it can also send a signal to a particular process: Process.kill (process.pid, ' SIGTERM '), where it sends the sigterm to the node process (Process.pid gets the PID number of the current node), so that your node, the process exits.

Well, I should remind you, what other methods and properties does this process have?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.