app.js
var http = require('http');
const module1 = require('./module1');
function onRequest(request,response){
response.writeHead(200,{'Content-type': 'text/plain'});
response.write(module1.myStr);
//module1.myfun();
response.end();
}
http.createServer(onRequest).listen(8000);
module1.js
function myfun(){
console.log("fun is called");
}
var myStr = 'String!!'
module.exports.myfun = myfun;
module.exports.myStr = myStr;
I have followed nodejs basic tutorial by academind and wrote down the exact same code.