第一个rails安装:Rake在没有javascript运行时的情况下中止

First rails install: Rake aborted no javascript runtime

本文关键字:运行时 javascript 情况下 安装 rails Rake 第一个      更新时间:2023-09-26

我正在学习一个安装rails的视频教程,在安装rails、gems和mysql之后,视频将遍历rakedb:create作为测试,以确保mysql正常工作。

c:'row'dev'Hello_World>rake db:create
DL is deprecated, please use Fiddle
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
c:/row/dev/Hello_World/config/application.rb:7:in `<top (required)>'
c:/row/dev/Hello_World/Rakefile:4:in `<top (required)>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
c:/row/dev/Hello_World/config/application.rb:7:in `<top (required)>'
c:/row/dev/Hello_World/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

我有点迷路了。如有任何帮助,我们将不胜感激。

由于它在评论中出现了几次,geminstall therubyracer给出了这样的结果:

ERROR:  Error installing therubyracer:
        ERROR: Failed to build gem native extension.
    c:/row/Ruby21/bin/ruby.exe extconf.rb
creating Makefile
which: no python in (.;c:'row'Ruby21'devkit'bin;c:'row'Ruby21'devkit'mingw'bin;c:'windows;C:'Program Files'MySQL'MySQL Server 5.7'bin;c:'row'Ruby21'bin)
The system cannot find the path specified.
which: no python in (.;c:'row'Ruby21'devkit'bin;c:'row'Ruby21'devkit'mingw'bin;c:'windows;C:'Program Files'MySQL'MySQL Server 5.7'bin;c:'row'Ruby21'bin)
c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:81:in `setup_python!': libv8 requires python 2 to be installed in order to build, but it is currently not available (RuntimeError)
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:55:in `block in build_libv8!'
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:52:in `chdir'
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:52:in `build_libv8!'
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/location.rb:24:in `install!'
        from extconf.rb:7:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13 for inspection.
Results logged to c:/row/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/libv8-3.16.14.13/gem_make.out

尝试安装therubyracer-gem

尝试修复它:

/usr/local/lib/rube/gems/ruby_ver/gems/execjs ver/lib/execjs/runtimes.rb

Node = ExternalRuntime.new(
      :name        => "Node.js (V8)",
      :command     => ["nodejs", "/usr/local/bin/node"],
      :runner_path => ExecJS.root + "/support/node_runner.js",
      :encoding    => 'UTF-8'
    )

根据情况,您可以将node.js安装到系统中。

在我的AmazonWS AMI EC2中,这修复了它。

粘贴到终端

gem install therubyracer

插入您的Gemfile

  gem 'uglifier', '~> 2.7', '>= 2.7.2'

运行

bundle install