質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

2523閲覧

Ruby on Rails6 チュートリアルのRails newでwebpacker関連のエラーがでる

knj

総合スコア37

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2021/01/31 05:05

前提情報

こちらで手順通りにすすめています。
https://railstutorial.jp/chapters/beginning?version=6.0#cha-beginning

Ruby version:3.0.0 Rails version:6.0.3

問題1

UNIX

1rails _6.0.3_ new hello_app 2

作成すると、一見問題なくRails newされ、bundle install(bundle update)できます。その後、Rails sで動作確認ができます。

ただ、Rails newのログをみると、以下のエラーが発生しています。

UNIX

1warning @rails/webpacker > node-sass > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 2warning @rails/webpacker > node-sass > node-gyp > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 3warning @rails/webpacker > node-sass > request > har-validator@5.1.5: this library is no longer supported 4warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. 5warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. 6warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated 7warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated 8[2/4] ???? Fetching packages... 9error @rails/webpacker@4.3.0: The engine "node" is incompatible with this module. Expected version ">=8.16.0". Got "8.14.0" 10error Found incompatible module. 11info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. 12Installing dev server for live reloading 13 run yarn add --dev webpack-dev-server from "." 14yarn add v1.22.10 15info No lockfile found. 16[1/4] ???? Resolving packages... 17warning webpack-dev-server > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. 18warning webpack-dev-server > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. 19warning webpack-dev-server > chokidar > braces > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated 20warning webpack-dev-server > chokidar > braces > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated 21[2/4] ???? Fetching packages... 22[3/4] ???? Linking dependencies... 23warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". 24warning " > webpack-dev-server@3.11.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". 25

error @rails/webpacker@4.3.0: The engine "node" is incompatible with this module. Expected version ">=8.16.0". Got "8.14.0"

これが一番怪しいので、nodeのバージョンが古いのか?と思ったのですが、node -vするとv14.15.4です。なので、要件はクリアしているよう。
いろいろとググったのですが、解決せず。。。

問題2

最悪、rails sをすれば動くのでいいのですが、これはherokuのデプロイに問題がありそうです。herokuにデプロイするとエラーがでてコンパイルに失敗します。

error Command "webpack" not found.

参考
https://teratail.com/questions/284927

webpackerを再インストールしても解決されません。
この歳、node_modulesのフォルダ内にはwebpackはなく、webpack-dev-serverのみあります。

試したこと

  • node_modulesフォルダを削除したり
  • yarnをインストールしなおしたり

ぐぐってでてくることあだいたいやった。
https://github.com/rails/webpacker/issues/512
https://github.com/rails/webpacker/issues/522

だれかお助けを〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

やはりnodeのバージョンがうまく設定できていないのが原因でした。
node -vで最新が表示されていたので、気づかなった。

この記事を参考にnvmではなく、nodenvを使って管理に変更した。

https://qiita.com/tonkotsuboy_com/items/5322d226b6783d25b5df

environmentで指定後、raile newで無事webpackがダウンロードされ解決

ちなみに、その後herokuはデプロイエラーがでた。

remote: ! remote: ! Could not detect rake tasks remote: ! ensure you can run `$ bundle exec rake -P` against your app remote: ! and using the production group of your Gemfile. remote: ! /tmp/build_a1decfde/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError) remote: ! from /tmp/build_a1decfde/config/boot.rb:4:in `<top (required)>' remote: ! from /tmp/build_a1decfde/bin/rake:7:in `require_relative' remote: ! from /tmp/build_a1decfde/bin/rake:7:in `<main>' ```remote: ! これを参考して解決。 [https://qiita.com/i05tream/items/8b64d6061a3589e5d242 ](https://qiita.com/i05tream/items/8b64d6061a3589e5d242) > herokuではbundlerが2.1.4までのバージョンのものしか使えない gemfile.lockではこう指定されていたので、それが原因ぽかった

BUNDLED WITH
2.2.7

下記のコマンド実行後再度herokuデプロイで成功した! ```ここに言語を入力 rm Gemfile.lock $ gem install bundler -v 2.1.4 $ bundle _2.1.4_ install --without production

投稿2021/01/31 06:54

knj

総合スコア37

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問