How to install and run Node.js on Mac OS
Install and Test Node.js on Mac OS
Download Node.js for Macintosh
Step 1: First download and install Node.js Macintosh installer from 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 require 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 code available in os module.
Save this example script as os.js file.
Now open your Command Prompt and change the directory to desktop.
Type node os.js
This script pull information from operating system and display in command line.
Try different operating system based utility functions in nodejs.