4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rails webpacker:install node-sass: Command failed.

Last updated at Posted at 2021-03-06

この記事について

rails webpacker:installを実行しようとすると以下のエラーが発生(node-sass部分)。
解決できたので備忘録投稿

$ rails webpacker:install                                                                                                                                                  e

なんやかんや。。。

warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[4/4] 🔨  Building fresh packages...
[-/2] ⠐ waiting...
error /Users/ketchamash/hello_rails/node_modules/@rails/webpacker/node_modules/node-sass: Command failed.
Exit code: 1

環境

Mac Catalina
ruby 2.6.3
rails 6.0.3

解決方法 & 参考記事

色々調べていると、nodejsのバージョンもしくはnode-sassバージョンに原因があることは分かった。どのバージョン同士でやったらええねん状態でしたが、こちらの記事でうまいこといきました。

nodejsとnode-sassのバージョンの対応表

nodejs -v node-sassのサポート -v
14 4.14+
13 4.13+, <5.0
12 4.12+
11 4.10+, <5.0
10 4.9+

実行コマンド

これでちゃんとインストールできやした〜。

nodebrewはNode.jsのバージョンを管理するためのツール

$ nodebrew install v14.15.0

$ nodebrew use v14.15.0

$ yarn add node-sass@4.14.0

$ rails webpacker:install

Webpacker successfully installed 🎉 🍰
4
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?