Install and Test Node.js on Ubundu Linux
Download Node.js for Linux
Step 1: First open Terminal.
Step 2: Install Node.js using app get
Type sudo app-get install nodejs. Hit return.
Next open Text editor. Type console.log(‘Application Working’);Save this file as test.js in your home directory.
Step 3: In your Terminal type node test.js. It run and make out put as “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 Terminal 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.