Rails server cannot be started in Cloud9

problem

After installing Rails on AWS Cloud9 for the first time, I got an error in the terminal when I tried to create a new app and launch a server.

Development environment

Error that occurred

Time series until the error occurs

Install Rails-v5 on Cloud9

$ gem install rails -v 5

Create a new 〇〇 app

$ rails new 〇〇

〇 〇 Move to the application directory

$ cd ~/environment/〇〇

Start the server

$ rails s -b $IP -p $PORT

: warning: ** Error occurred **: warning:
Looking at the error statement in the terminal, the error content was as follows.

Please run rails webpacker:install Error: No such file or directory

The error is that ** webpacker ** is not installed. It is the content.

Solution Install webpacker and yarn

I found out that the cause was that webpacker was not installed, so

$ rails webpacker install

Install ** webpacker **. At this time, ** yarn ** was not installed, so the following error occurred.

Yarn not installed. 
Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/

The error is that ** yarn ** is not installed. It is the content. ** yarn ** is required to install ** webpacker **, so install ** yarn ** first.

$ npm install -g yarn

Install ** yarn ** with the command. After installing ** yarn **, then install ** webpacker **.

$ rails webpacker install

If you can install ** webpacker **, it's OK.

After installing ** yarn ** and ** webpacker **, start the server again.

$ rails s -b $IP -p $PORT

The server started up successfully: thumbs up:

Supplement

** webpacker: ** A Gem file that enables Rails to use webpack. It is for improving communication speed by combining JavaScript and CSS into one.

** yarn: ** JavaScript package manager. Mechanism for managing JavaScript

Recommended Posts

Rails server cannot be started in Cloud9
Windows10 "rails s" cannot be started. Unable to access localhost: 3000
[rails] Problems that cannot be registered / logged in with devise
React.js CSS in Rails app deployed on EC2 cannot be loaded
[Rails] Rails new cannot be done from Docker
[Rails] Posts cannot be deleted when commented! ??
About the problem that the server can not be started with rails s
767 JSON :: ParserError occurs and the problem that the local server cannot be started
Cloud IDE: Heroku couldn't be installed in the Ruby on Rails tutorial
[Rails 6] method :: delete cannot be used with link_to
Java.home cannot be set in visual studio code.
Rails error messages cannot be translated into Japanese
Group_by in Rails
500 Internal Server Error occurs in Rails production environment
[Ruby on Rails] How to stop when Rails server cannot be stopped by Ctrl + C
[Android] Solution when the camera cannot be started on Android 9
Tomcat cannot be started due to java version change
What to do if rails server can't be stopped
Regarding overcapacity when setting Rails tutorial environment in Cloud 9
Model association in Rails
Adding columns in Rails
Disable turbolinks in Rails
CSRF measures in Rails
^, $ in Rails regular expression
Use images in Rails
Understand migration in rails
Split routes.rb in Rails6
Cloud9 (Rails) from Github
Rails server doesn't start.
Implement markdown in Rails
[Rails] Where to be careful in the description of validation