我试图使用蒙古/设计Rails 3.1模板(蒙古和设计),我一直得到一个错误说明ExecJS找不到JavaScript运行时。公平的时候,我没有安装任何,但我已经尝试安装Node.js, Mustang和Ruby Racer,但没有工作。

我找不到JavaScript运行时。参见sstephenson/ExecJS (GitHub)获取可用运行时的列表(ExecJS::RuntimeUnavailable)。

我需要做什么才能让它工作?


当前回答

尝试在RubyMine中使用Ubuntu 18.04, Ruby 2.6进行调试。*, Rails 5和RubyMine 2019.1.1,我遇到了同样的问题。

为了解决这个问题,我从我的Gemfile中取消了mini_racer行,然后运行bundle:

# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

改变:

# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'mini_racer', platforms: :ruby

其他回答

尝试在RubyMine中使用Ubuntu 18.04, Ruby 2.6进行调试。*, Rails 5和RubyMine 2019.1.1,我遇到了同样的问题。

为了解决这个问题,我从我的Gemfile中取消了mini_racer行,然后运行bundle:

# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

改变:

# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'mini_racer', platforms: :ruby

不要使用RubyRacer,因为它对内存不好。按照某些人的建议安装Node.js是一个更好的主意。

ExecJs库可以使用的可用运行时列表也记录了Node.js的使用

https://github.com/sstephenson/execjs

所以,Node.js并不是一个多余的,而且比使用RubyRacer更好的解决方案。

对于amazon linux(AMI):

sudo yum install nodejs npm --enablerepo=epel

2022年Mac的答案很简单:

编译安装nodejs

然后重新运行rails服务器。

添加以下宝石到我的Gemfile解决了这个问题:

gem 'therubyracer'

然后捆绑你的新依赖项:

$ bundle install