LoginSignup
2
3

More than 3 years have passed since last update.

rails sでサーバーが立ち上がらないとき

Last updated at Posted at 2020-12-16

概要

Webpacker::Manifest::MissingEntryError
このようなエラーが起きた時ひとつの解決策としてお役に立てれば幸いです。

環境

Mac OS Catarina 10.15.7
rails 6.0系
ruby 2.6.5

エラー文

1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:

image.png

試したこと

1.webpackをインストール
2.yarnが入っているかの確認
3.yarnのupgrade
4../bin/webpack-dev-serverでサーバー立ち上げ

application.html.erbjsを読み込む記述を消せばエラーは消えるのですが、jsを読み込むことができなくなってしまいます。

解決策

nodeのバージョンが異なっているためエラーが起きておりました。

ゴールはnodeのバージョンを合わせてサーバーが立ち上がることを確認することです。

解決の流れ

1.nodeのバージョン確認
2.nodeのダウングレードするために削除・再インストールする
3.nodeのバージョン確認
4.インストールしたnodeが反映されていなかったらPATHを通す
5.Webpackerをインストールする
6.yarnが必要というエラーが起きたらyarn install
7.再度Webpackerをインストール
8.サーバーを立ち上げて確認

詳細

1.nodeのバージョン確認
2.nodeのダウングレードするために削除・再インストールする
3.nodeのバージョン確認

ターミナル
% node -v
% brew uninstall --ignore-dependencies nodejs
% brew install node@14
% node -v

4.インストールしたnodeが反映されていなかったらPATHを通す

ターミナル
% vim ~/.zshrc 
% source ~/.zshrc
vim
export PATH="/usr/local/opt/node@14/bin:$PATH" 

5.Webpackerをインストールする

ターミナル
% rails webpacker:install

6.yarnが必要というエラーが起きたらyarn install

ターミナル

========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================
ターミナル
% yarn install

7.再度Webpackerをインストールしてみる

ターミナル
% rails webpacker:install

8.サーバーを立ち上げて確認

ターミナル
% rails s

まとめ

  • Webpackerをインストールするにはyarnが必要。
  • バージョンの違いで読み込めないということも起こることがある。
2
3
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
2
3