is it possible node.js to start js files which are not located on the same machine where the node is started? (Something like node.exe http://myserver.com/app.js )
Thanks!
If you want to execute the file locally you could retrieve the remote file and then execute it locally.
Otherwise you'll have to configure (probably by writing a script in Node, PHP, or whatever your preferred web scripting language is) the remote server to execute the file itself when you make a certain request. This has security implications, however—you'll need to take measures to protect against unauthorized requests using, say, HTTP basic authentication.
You could also do something like this:
var http = require('http');
var url = 'url-to-js';
var script = '';
http.get(url, function(res) {
res.on('data', function(d) {
script+=d.toString();
});
}).on('close', function(e) {
eval(script);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.