I am new to learning node.js and I downloaded all the components on ubuntu. I have written a test, helloworld app, but it does not work for some reason. Here's my file layout.
When I execute which nodejs, the terminal returns /usr/bin/nodejs
When I execute which npm, the terminal returns /usr/bin/npm
My app.js test file is located in /home/tarang/node/helloWorld
Here's the source for the app.js
//creating http server
var http = require('require');
http.createServer(function(req, res){
res.writeHead(200, {'Context-Type': 'text/plain'});
res.end('helloWorld');
}).listen(8000);
console.log('server running');
UPDATE
When i execute nodejs app.js, i obtain the following error
Error: Cannot find module 'require'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/tarang/node/helloWorld/app.js:4:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
Please do explain since I am new to ubuntu and nodejs.
Thanks!
UPDATE
Do i need to update to the lastest verions of express, node and npm?