[RUBY] What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server

Starting up a server that was possible with windows cannot be done with a Mac that I just bought. As a result of various investigations, I managed to do it, so I summarized it.

error contents

Progate's "Let's build a Ruby on Rails environment! (MacOS)", proceed to "5. Set up a Rails server locally", and when the rails s command is executed, the following error occurs.

% rails s
  (Abbreviation)
Could not find a JavaScript runtime. 
See https://github.com/rails/execjs 
for a list of available runtimes. 
(ExecJS::RuntimeUnavailable)
 

Even if I enter localhost: 3000 in the browser, it is not displayed with an error. Apparently there is an error because there is no JavaScript runtime. I found the following article when I searched without knowing the runtime.

https://wa3.i-3-i.info/word13464.html

According to the article

What is runtime (English: runtime)?

When running a program (at runtime).

Or

Parts required to run programs

And that. In other words Ruby itself does not have a function to execute JavaScript, and a runtime is required to execute it </ b> It seems that.

Until resolution

For the time being, I searched on the net for Could not find a JavaScript runtime. And found an article on the Ruby on Rails tutorial.

https://railstutorial.jp/chapters/beginning?version=4.0#sec-rails_server

According to the article

(If you get an error that the JavaScript runtime is not installed, check the installable runtime on the execjs page on GitHub. Node.js is especially recommended).

And that. Immediately access the GitHub site in the error text.

https://github.com/rails/execjs

Click Node.js, download from the official website and install. After that, when I ran rails s with the command again, the server started up.

Recommended Posts

What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server
[Rails] What to do if you get an error saying "Could not find a JavaScript runtime." When executing the rails s command on Catalina
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
What to do if you get an error when you hit Heroku logs
What to do if you get the error Couldn't find Item without an ID
What to do if you get a port error when docker-compose up on Mac
Many error lines ... Rails server does not start 2. "Autodetect': Could not find a JavaScript runtime."
What to do if you get a gcc error in Docker
What to do if you get a DISPLAY error in gym.render ()
[Rails] What to do if you can't get an error message with the errors method
What to do if you get a "302" error in your controller unit test code in Rails
What to do if you get an error in Basic authentication during Rails test code
[Java] What to do if you get an error in Eclipse saying "Not allowed at source level below 1.X"
What to do if you get an error saying Cannot find a valid baseurl for repo when you use yum -y install docker in a udemy course using CentOS7
What to do if you get an uninitialized constant Likes Controller error
What to do if you get a "Mysql2 :: Error: Operand should contain 1 column (s)" error in Rails
What to do if you get a JNI shared library error when trying to build in Eclipse
<Dot installation> What to do if you cannot proceed due to an error when building a development environment for Rails learning.
What to do if you get a SQLite3 :: BusyException: database is locked error
What to do if you get an error on heroku rake db: migrate
What to do if you get Could not save master table to file after importing a project in Eclipse
What to do if you get a wrong number of arguments error in binding.pry
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
How to deal with errors in Rails s could not find a JavaScript runtime.
What to do if you get a java.io.IOException in GlassFish
[Error resolution] How to resolve the error "Could not find a JavaScript runtime." After upgrading Catalina!
What to do when a could not find driver appears when connecting to a DB in a Docker environment
[Rails] What to do if you can't get parameters with form_with
How to make a jar with old Hadoop (hadoop-core-0.20.2-cdh3u6) in Gradle: (What to do if you get Could not expand ZIP ..)
What to do if you get an [An HTTP request took too long to complete.] Error in Docker.
What to do if you get "Changes not staged for commit:" when you git status after git add.
What to do if you get a groovy warning in Thymeleaf Layout
What to do if an error occurs when nokogiri enters when bundle install
What to do if you get a MiniMagick vulnerability alert on GitHub
When I did rails new, I got an error saying PG :: ConnectionBad: could not connect to server: No such file or directory
What to do if you get an error with bundle install by entering gem'bcrypt' in your Gemfile
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you get the error message unrecognized selector send to instance "***"
What to do if ffi installation fails when launching an application in Rails
What to do if the Rails server can't start
What to do if ClassNotFoundException occurs when starting Tomcat
What to do if rails server can't be stopped
What to do if you accidentally create a model
What to do when a null byte error occurs
What to do when rails creates a 〇〇 2.rb file
What to do if an ActionController :: UnknownFormat error occurs
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
What to do if you can't get the text of an element in Selenium
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
What to do if you get an Argument Error: wrong number of arguments (given 2, expected 0) in your RSpec test
# What to do if you accidentally do rails db: migrate: drop
What to do if mysql2 gets a bundle install error
What to do if you can't use the rails command
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
[Rails 6] What to do when a missing a template error occurs after introducing haml [Super easy]
What to do if you select a JRE in Eclipse and get "The selected JRE does not support the current compliance level 11"
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
What to do if you go offline due to SSL certificate error when running Jenkins on Mac