- Windows 7 (64 bit)
- Node.js 4.4.2 (64 bit)
- Path already contains node executable so when you open up command prompt and type “node” and hit Enter key, it will be ready to accept node commands.
- BASE_DIR = “C:\temp\nodejs\”. This is where I have my source code stored.
var fs = require('fs'); // Read and eval library filedata = fs.readFileSync('./node_modules/helloworld/lib/helloworld.js','utf8'); eval(filedata); exports.HelloWorld = HelloWorld;
//Import helloworld module var hello = require('helloworld'); // Create an object var hw = new hello.HelloWorld(); // Execute object method console.log(hw.sayHello());
How to execute?
- Open Windows Explorer and navigate to BASE_DIR.
- Press Shift key and right click on the Windows Explorer in open space and then click on “Open command prompt here” to open up command prompt
Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1’s and 0’s from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.