How can I invoke Ruby from Node.js?

笑着哭i 提交于 2019-11-30 13:56:13

问题


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?


回答1:


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?



来源:https://stackoverflow.com/questions/8101137/how-can-i-invoke-ruby-from-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!