LoginSignup
3
1

More than 1 year has passed since last update.

M1でnode-sass使えない問題をRosetta2で解決する

Posted at

起こったこと

チームで環境構築を行なった際、yarn install, npm installで怒られる。

error /Users/.../node_modules/node-sass: Command failed.

webによると、M1(arm)にnode-sassが対応していない模様。

環境

  • macOS Monterey バージョン12.3.1
  • MacBook Pro(13-inch, M1, 2020)

結論

nodeをRosetta2上で動かす。
パフォーマンスは落ちるが、一応動く。

方法

Rosetta2環境のzshを起動する。

$ arch -x86_64 zsh

この状態で、nodeをインストールする。

$ nvm install 使用したいバージョン
$ nvm use 上でインストールしたバージョン

適切なディレクトリ下で、npm (or yarn) installする。

$ cd 目的のディレクトリ
$ npm install
or
$ yarn install

あとはnpm runなりyarn runなりすればOK。

所感

Rosetta2を使わずarm上で解決できれば良かったのだが、うまい方法が見つからなかった and 思いつかなかった。

「チームではnode-sass使ってるが、自分のマシンはM1...」
という人は、とりあえずはこれで動く。

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