Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I invoke Ruby from Node.js?

There are several ways for running JavaScript inside of a Ruby script. For example, there is ExecJS which is frequently used for porting NPM modules to Ruby. So, is there a "ExecRuby" for Node?

like image 573
user544941 Avatar asked Nov 11 '11 23:11

user544941


People also ask

How do I invoke node js?

The usual way to run a Node. js program is to run the globally available node command (once you install Node. js) and pass the name of the file you want to execute. While running the command, make sure you are in the same directory which contains the app.

Is node js faster than Ruby?

Another reason that Node. js is faster than Ruby on Rails is that it can handle more requests. The web programming app is able to manage more server workloads. Websites and online apps using Node.

What is Ruby node?

Ruby on Rail. 1. Node. js is a JavaScript run-time environment framework that is written in JavaScript. Rails is a Ruby-based framework, which is written in Ruby language.


1 Answers

You can invoke Ruby like any other shell command using child_process.exec()

var exec = require("child_process").exec;

exec('ruby -e "puts \'Hello from Ruby!\'"', function (err, stdout, stderr) {
    console.log(stdout);
});

Don't know if that's what you're looking for?

like image 162
Flambino Avatar answered Sep 28 '22 02:09

Flambino