0
1

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 1 year has passed since last update.

error /node_modules/node-sass: Command failed.の対処法

Posted at

mac OS バージョン11.6
エディタ…VScode
Rails 6.0.4

やりたいこと

yarnコマンドがエラーなく通るようにしたい。

エラー内容

% yarn add jquery
(省略)
error /node_modules/node-sass: Command failed.

yarn installや他のyarnコマンドも試しましたが、全部同じエラー。

原因

nodejsのバージョンもしくはnode-sassバージョンに原因があるみたい。
これからバージョンを正しく指定していきます。

解決策

初めに % nodebrew install v14.15.0 を試すがエラーが出る。

まずはNodebrewをインストールする必要があるみたい。


・インストール

% brew install nodebrew

・確認
nodebrew -v
バージョンが表示されればOK。

・環境変数を追加
ターミナルで以下を実行。

export PATH=$HOME/.nodebrew/current/bin:$PATH

bash_profileを更新して設定を反映させる。

source ~/.bash_profile

・セットアップ。これやらないとインストールできない。
nodebrew setup




あとはバージョンを指定してインストールしていきます。
% nodebrew install v14.15.0

% nodebrew use v14.15.0


% yarn add node-sass@4.14.0
yarn add v1.22.17
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 5 new dependencies.
info Direct dependencies
└─ node-sass@4.14.0
info All dependencies
├─ invert-kv@1.0.0
├─ lcid@1.0.0
├─ node-sass@4.14.0
├─ os-locale@1.4.0
└─ sass-graph@2.2.6
✨  Done in 30.25s.

この後 % yarn add jqueryも試しましたが無事実行できました!

参考

https://qiita.com/ashketcham/items/70763df042db23947728
https://qiita.com/mame_daifuku/items/373daf5f49ee585ea498

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?