gpt4 book ai didi

javascript - rake 中止!找不到 JavaScript 运行时

转载 作者:太空宇宙 更新时间:2023-11-03 17:02:32 24 4
gpt4 key购买 nike

我是 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

我做了 rake ……扑通一声!

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)>'

请帮帮我

最佳答案

原因不言自明,表示 JS 运行时不可用。您可以通过将 rubyracer gem 添加到您的 Rails 应用程序来显式添加该依赖项,这应该包括 JS 运行时,对您来说。

因此,将 gem 'therubyracer' 添加到您的 Gemfile 中,然后再次运行 bundle 命令。然后,您可以根据需要运行 rakerails 命令:)

如果这不能解决您的问题,请在您的系统上安装 node.js,这肯定会解决您的问题。您可以使用:

sudo apt-get install nodejs # on ubuntu
brew install node # on mac-osx, if you have `homebrew` installed.

关于javascript - rake 中止!找不到 JavaScript 运行时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20790715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com