Loading remote js file using require with node.js
Take a look at the node.js modules docs
Specifically, refer to the require algorithm
Within node.js, require
calls are synchronous, so it's not possible to load files that are not on your file system (ie, from an external url).
Update
You could fetch the code through an http request - or, even better, an https request and run it with the built-in vm module - or even with eval
, but that seems not a good idea - as suggested on this old question.
Something like
https.get( 'https://www.xxxxx.com/blabla/forza4.js', function( res ){
res.on( 'data', function( data ){
vm.runInThisContext( data, 'remote/forza4.js' );
});
});
Note: I did not test this code
Sure it isn't the best solution, but is a solution.