LoginSignup
0
0

More than 3 years have passed since last update.

Rails6環境構築時に発生した"webpacker"と"yarn"の未導入が原因のエラーとその解決方法

Posted at

はじめに 

rails tutorial(第6.0版)を参考にrails6の環境を構築したところ、rails server立上げの際にエラーが発生しました。

原因は"webpacker"と"yarn"の未導入でした。

今後のために、エラー内容と"webpacker"と"yarn"の導入方法を備忘録として残します。

参考記事

Rails6 開発時につまづきそうな webpacker, yarn 関係のエラーと解決方法
Rails6 Webpackerでエラーが出た
Ubuntu18.04LTSにlinuxbrew(linux版homebrew)を入れる

開発環境

Cloud9 (ubuntu server)
Ruby 2.6.3
rails 6.0.0

エラー発生までの経緯

rails tutorial(第6.0版)第1章を参考にrails6の開発環境を構築開始。
1.3.1までチュートリアル通り実施し、rails severコマンドを入力すると、

{略}
rescue in load': Webpacker configuration file not found /home/ubuntu/environment/hello_app/config/webpacker.yml. Please run rails webpacker:install \
Error: No such file or directory @ rb_sysopen - /home/ubuntu/environment/hello_app/config/webpacker.yml (RuntimeError)

上記エラーが表示されました。

エラーの内容

/hello_app/config/ 内に"webpacker.yml"が存在しないから、webpackerをインストールしなさい。・・・と理解しました。

webpackerとyarnのインストール

webpacker導入コマンド

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

yarnがないと返事が来た場合。

yarn導入コマンド

$ brew install yarn
Command 'brew' not found, but can be installed with:

上記の返事が来た場合。

$ sudo apt install linuxbrew-wrapper

yarnとwebpackerを再度導入する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0