节点的模块度
Node modules are like libraries which help us perform specific tasks. Node.js is always considered powerful because it has a very large ecosystem of third-party modules.
节点模块就像库一样,可以帮助我们执行特定任务。 Node.js一直被认为功能强大,因为它具有非常庞大的第三方模块生态系统。
The OS module is a built-in module used to get information about the computer's operating system and other important information about a system.
OS模块是一个内置模块,用于获取有关计算机操作系统的信息以及有关系统的其他重要信息 。
Take Note! You should have Node js in your PC.
做记录! 您的PC中应该有Node js。
With Node.js already up and running, let's get started.
在Node.js已经启动并运行的情况下,让我们开始吧。
Now, let's get started.
现在,让我们开始吧。
The OS module is an object where we make use of it's various properties to get the information we desire.
OS模块是一个对象,我们可以利用它的各种属性来获取所需的信息。
For example, os.arch() gives us the operating system CPU architecture.
例如, os.arch()为我们提供了操作系统CPU体系结构 。
Below, we'll see how to get information about the computer's free memory, platform, architecture and host name on the console.
在下面,我们将看到如何在控制台上获取有关计算机的可用内存,平台,体系结构和主机名的信息。
Open a text editor and type the following code and save it with the file name app.js:
打开一个文本编辑器,输入以下代码,并将其保存为文件名app.js :
const os = require('os'); // include the OS module
console.log("Platform: " + os.platform());
console.log("Architecture: " + os.arch());
console.log (" Free memory: " + os.freemem() );
console.log("Host name: " + os.hostname());
Note: The file should be saved in your default Node.js directory.
注意:该文件应保存在默认的Node.js目录中。
Run the code by initiating the file at the command prompt like a regular Node.js file.
通过在命令提示符处启动文件(如常规Node.js文件)来运行代码。
![Node OS module](https://www.includehelp.com/node-js/Images/node-os-module.jpg)
翻译自: https://www.includehelp.com/node-js/node-os-module.aspx
节点的模块度