找不到JavaScript运行时错误

时间:2015-12-03 07:31:32

标签: javascript ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4

我在rails4中设置了一个项目,当我尝试启动服务器时它没有出现此错误。一切似乎都很好,但我不知道出了什么问题。这是错误:

neha@ubuntu:~/Desktop/myapp$ rails s -p 3001
/home/neha/.rvm/gems/ruby-2.2.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home/neha/.rvm/gems/ruby-2.2.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
from /home/neha/Desktop/myapp/config/application.rb:7:in `<top (required)>'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/neha/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

I am using Rails 4 on ubuntu 14.04

1 个答案:

答案 0 :(得分:1)

运行此命令安装node.js,错误将被修复。

sudo add-apt-repository ppa:chris-lea/node.js 
sudo apt-get -y update 
sudo apt-get -y install nodejs