没有js的运行环境导致的:
lijg@lijg-desktop:~/workruby/helloapp$ ruby script/rails console
/home/lijg/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.7/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime . See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
解决方法1:
Adding the following gems to my Gemfile solved the issue:
gem 'execjs'
gem 'therubyracer'
Then of course:
bundle install
解决方法2:
安装nodejs
lijg@lijg-desktop:~/workruby/helloapp$ sudo apt-cache search nodejs
[sudo] password for lijg:
coffeescript - interpreter and compiler for the CoffeeScript language
nodejs - Node.js event-based server-side javascript engine
nodejs-dbg - Node.js event-based server-side javascript engine (debug)
nodejs-dev - Development files for Node.js
lijg@lijg-desktop:~/workruby/helloapp$ ruby script/rails console
/home/lijg/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.7/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime . See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
解决方法1:
Adding the following gems to my Gemfile solved the issue:
gem 'execjs'
gem 'therubyracer'
Then of course:
bundle install
解决方法2:
安装nodejs
lijg@lijg-desktop:~/workruby/helloapp$ sudo apt-cache search nodejs
[sudo] password for lijg:
coffeescript - interpreter and compiler for the CoffeeScript language
nodejs - Node.js event-based server-side javascript engine
nodejs-dbg - Node.js event-based server-side javascript engine (debug)
nodejs-dev - Development files for Node.js
本文详细介绍了在使用Ruby编程时遇到JavaScript运行环境缺失的问题,并提供了两种有效的解决方案:通过添加特定gem来解决环境问题,或者直接安装Node.js。文中还附带了详细的步骤指引和相关软件包的安装说明。
252

被折叠的 条评论
为什么被折叠?



