I would like to execute an JS file passed in argument in my NodeJS app (without require each others)
Example :
$ node myapp test.js
test.js
console.log("Do some work")
test();
myapp.js
var test = function(){ console.log("Test working");
here_execute_js_in_process.argv[2]();
I tried the simplest option, read file thanks to fs.readFile and eval resulted data :
fs.readFile(script, function(err,data){
if(err) console.log(err);
eval(data);
});
but didn't worked, have you got a any solution ?