LoginSignup
1
0

More than 3 years have passed since last update.

[Rails 6]でrails sしたらwebpackerでエラーした

Last updated at Posted at 2021-02-18

rails s したらエラーメッセージからwebpackerをインストールを実行を読み取る

Rails6.1.2.1とRuby3という最新バージョンでアプリ作成をして、
rails sをしようとしたら、早速エラーを吹いた。
とりあえずエラーメッセージを追っていったら、
Please run rails webpacker:install
との事。

% rails s
=> Booting Puma
=> Rails 6.1.2.1 application starting in development
=> Run `bin/rails server --help` for more startup options
Exiting
/Users/<ユーザー名>/<アプリディレクト>/<アプリ名>/vendor/bundle/ruby/3.0.0/gems/webpacker-5.2.1/lib/webpacker/configuration.rb:99:in `rescue in load': Webpacker configuration file not found /Users/<ユーザー名>/<アプリディレクト>/<アプリ名>/config/webpacker.yml. **Please run rails webpacker:install** Error: No such file or directory @ rb_sysopen - /Users/<ユーザー名>/<アプリディレクト>/<アプリ名>/config/webpacker.yml (RuntimeError)

rails webpacker:installしてみよう

せっかくのヒントなので早速rails webpacker:install

順調にいくと、
├─ which-module@2.0.0
├─ which@1.3.1
├─ wrap-ansi@5.1.0
├─ ws@6.2.1
├─ y18n@4.0.1
├─ yargs-parser@13.1.2
└─ yargs@13.3.2
✨ Done in 14.73s.
Webpacker successfully installed 🎉 🍰

インストールされたよと、ハッピーな感じに。

途中のエラーメッセージは後々に。

インストール最中にエラーメッセージが出ることもあります。
こういったものは、今は直接関係はないが、よくよくというという時もあります。
とりあえず今回はよくよくで。
Installing all JavaScript dependencies [5.2.1]
run yarn add @rails/webpacker@5.2.1 from "."
yarn add v1.22.10
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning @rails/webpacker > node-sass > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > node-gyp > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > request > har-validator@5.1.5: this library is no longer supported
warning @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.
warning @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.
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
[1/3] ⢀ fsevents
[-/3] ⢀ waiting...
**error /Users/<ユーザー名>/<アプリディレクト>/<アプリ名>/node_modules/node-sass: Command failed.
Exit code: 1**
Command: node scripts/build.js
Arguments:
Directory: /Users/<ユーザー名>/<アプリディレクト>/<アプリ名>/node_modules/node-sass
Output:
Building: /usr/local/Cellar/node/15.8.0/bin/node /Users/<ユーザー名>/<アプリディレクト>/<アプリ名>/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=

yarnとnode関係で今後エラーを踏みそうです。

rails sをしてみる

webpakerは無事にインストールさせる事ができたので、
rails sしてみる。

% rails s
=> Booting Puma
=> Rails 6.1.2.1 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.2.1 (ruby 3.0.0-p0) ("Fettisdagsbulle")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 3839
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop
Started GET "/" for ::1 at 2021-02-18 20:24:24 +0900
(6.8ms) SELECT sqlite_version(*)
Processing by Rails::WelcomeController#index as HTML
Rendering vendor/bundle/ruby/3.0.0/gems/railties-6.1.2.1/lib/rails/templates/rails/welcome/index.html.erb
Rendered vendor/bundle/ruby/3.0.0/gems/railties-6.1.2.1/lib/rails/templates/rails/welcome/index.html.erb (Duration: 16.7ms | Allocations: 525)
Completed 200 OK in 78ms (Views: 35.7ms | ActiveRecord: 0.0ms | Allocations: 6869)

スクリーンショット 2021-02-18 20.24.38.png

これでやっとスタート地点ですね!

エラーメッセージは友達

エラーメッセージからヒントは沢山ある。
エラーとバグは敵だけど、
エラーメッセージは友達になりたいね。

4児パパブログ

1
0
1

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
1
0