我是Ruby的初学者,我在启动时遇到了一些麻烦
我创建了一个演示项目:
C:\Sites>rails new demo
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/javascripts/application.js
...
create vendor/assets/stylesheets/.keep
run bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using mail (2.5.4)
Installing actionmailer (4.0.2)
...
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed
接下来,选择文件夹:
C:\Sites>cd demo
我耙了耙......然后噗!
C:\Sites\demo>rake about
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
C:/Sites/demo/config/application.rb:7:in `<top (required)>'
C:/Sites/demo/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
我试过运行服务器......但不能正常工作
C:\Sites\gui>rails server
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/execjs-2.0.2/lib/execjs/run
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi
thub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUn
available)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/execjs-2.0.2/l
ib/execjs.rb:5:in `<module:ExecJS>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/execjs-2.0.2/l
ib/execjs.rb:4:in `<top (required)>'
帮助我,请。
答案 0 :(得分:12)
原因是非常自我解释,并说JS运行时不可用。您可以通过向rails应用程序添加rubyracer
gem来显式添加该依赖项,并且应该包含JS运行时。
因此,将gem 'therubyracer'
添加到Gemfile
,然后再次运行bundle
命令。然后,您可以根据需要运行rake
或rails
命令:)
如果这不能解决您的问题,请在您的系统上安装node.js
,这应该可以解决您的问题。您可以使用:
sudo apt-get install nodejs # on ubuntu
brew install node # on mac-osx, if you have `homebrew` installed.
答案 1 :(得分:0)
您需要一个javascript运行时。
从此处http://nodejs.org/安装node.js.确保将可执行文件添加到PATH。