rake db:create - 找不到 JavaScript 运行时 [英] rake db:create - Could not find a JavaScript runtime

查看:29
本文介绍了rake db:create - 找不到 JavaScript 运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我得到的错误:

sergio@sergio-VirtualBox:~/blog$ rake db:create
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

(See full trace by running task with --trace)

sergio@sergio-VirtualBox:~/blog$ 

所以经过一番搜索后,我似乎需要为 Ruby 安装一个 Javascript 运行时.

So after some searching it seems I need to install a Javascript runtime for Ruby.

许多不同的选项之间有区别吗?看来 Node.js 是最容易安装的,这会回来咬我还是这个选择可以?

Is there a difference between the many different options? It seems Node.js is the easiest to install, will this come back to bite me or is this choice OK?

这个答案,似乎是我正在寻找的,但我不不知道怎么用.我在哪里可以找到这个gemfile",它是每个 rails 项目文件还是全局 ruby​​ 文件?我很困惑,似乎无法理解我的方向,多个答案相互矛盾,无法解决问题.

This answer, seems to be what I'm looking for but I don't know how to make use of it. Where do I find this "gemfile" and is it a per rails project file or a global ruby file? I'm very confused and can't seem to get my bearings and multiple answers contradict each other and don't solve the issue.

将此添加到您的 Gemfile

Add this to your Gemfile

gem 'therubyracer',需要:v8"

gem 'therubyracer', require: "v8"

然后运行

捆绑安装

推荐答案

Ruby 本身不需要 JS 运行时,但默认的新 Rails 应用程序需要.

Ruby itself doesn't require a JS runtime, but a default new Rails application does.

在您的主应用程序目录(即每个 Rails 项目)中有一个名为 Gemfile 的文件,它是您的项目所需的 gem 列表,您可以使用 bundle install.

There's a file called Gemfile in your main application directory (i.e. per Rails project) which is a list of gems required for your project that you can install using bundle install.

添加行 gem 'therubyracer' 然后 bundle install 将安装 ruby​​ Racer JS 运行时,如果您使用,我发现这是最简单的64 位操作系统.

Adding the line gem 'therubyracer' and then bundle install will install the ruby racer JS runtime, which I've found to be the simplest if you're on a 64bit OS.

您可以在 Bundler 网站上找到有关您的 Gemfile 的更多信息.

You can find more information about your Gemfile at the Bundler site.

这篇关于rake db:create - 找不到 JavaScript 运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆