Thursday, 11 May 2017

Running JavaScript on Ubuntu terminal gives no output

I am trying to execute a javascript function on a cloud ubuntu machine. Here's the code:

exports.msg = function(){
    console.log('This is a test function');
}


Now whenever I run this using nodejs on Windows using the command node test.js assuming the filename is test.js it works perfectly and prints the output. But whenever I install nodejs (Version 4.x) on Ubuntu and try running nodejs test.js the console runs with no output what so ever. No errors, no output, no nothing.
I referred to this question but I don't want to use Rhino. I want to use Nodejs. What am I doing wrong.
P.S. I know that nodejs runs using nodejs on Ubuntu and using node on Windows so this is definitely not the problem. Plus if you try running node test.js on Ubuntu without diverting the path of the executable from nodejs it will give an error.
I really don't know what I am missing here. Does nodejs has some log file in Ubuntu that I should check for the output? I tried checking the system log files with no luck.
Thanks.



via omarwaleed

No comments:

Post a Comment