Install and Test Node.js on Mac OS
Download Node.js for Macintosh
Step 1: First download and install Node.js Macintosh installer from the official website. You need to install Xcode on your mac.
Step 2: Open terminal and type mate node.js. Its open Text mate
Type console.log(‘Application Working’); and save the file.
Step 3: Next type node test.js in terminal. press enter button.
Its show ‘Application Working”.
var os = require("os"); var msg = 'Your System running under '+ os.platform() +' OS.'; console.log(msg);
The first one is the required function.
var os = require("os");
When you use a require statement, node searches for what’s called a module. In this case, we specify to load os module. Require function return the object which represents all of the code available in os module.
Save this example script as os.js file.
Now open your Command Prompt and change the directory to the desktop.
Type node os.js
This script pulls information from the operating system and displays in the command line.
Try different operating system based utility functions in nodejs.