What should I do if I get "Could not find a JavaScript runtime." while running the test?

Asked 2 months ago, Updated 2 months ago, 1 views

When I was developing Rails, I was developing using rbenv, but there was a little trouble, so I renewed my development environment.

If you run ./bin/rake test after doing bundle install, you will get the following error:

FoobarsControllerTest#test_should_get_new:
ActionView::Template::Error:cSee https://github.com/sstephenson/execjs for a list of available runtimes.
 (in/home/essehara/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
  app/views/layouts/application.html.erb:6:in`_app_views_layouts_application_html_erb_3074344629272133642_70077899278000'
  test/controllers/foobar_controller_test.rb:16:in`block in<class:FoobarsControllerTest>'

I remember that the above error did not occur in the previous environment.Why do we need execjs like this?Also, what is the fundamental solution to this?

For your information, I tried bundle install in the following rbenv environment, but I get an error using any of them:

  • ruby 2.1.0
  • ruby 2.2.0
  • ruby 2.2.1

If there is a correct solution to this error, please let me know.

ruby ruby-on-rails

2022-09-30 12:09

1 Answers

"See https://github.com/sstephenson/execjs for a list of available runtime." or "execjs node.js" gives you a lot of similar errors.
My acquaintance had a problem with the same error before.

I remember that it was fixed after reinstalling node.js.
(It says "new development environment", so I think we need to set up that kind of middleware.)

I'll give you a few links to the sources, so you can try them out.

Please let me know what would have been effective if it went well.


2022-09-30 12:09

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.