Setup Rails 5 Webpacker on silicon MacBook
The new MacBook seems to hate the legacy project LOL
If the new macOS version installs node-sass
with an error that python2
cannot be found, see here to install python2
first.
If still getting a bunch of compilation errors, after node-sass
is installed. Check if the node
and yarn
versions are too high. For example in our yarn.lock
, it is node-sass "^4.12.0"
, which, according to here, corresponds to the highest version of node
12. As for yarn
, it corresponds to version 1.x.
The lower version of node
on the m1 MacBook may have problems running webpack
. We can solve it by installing the x86-compatible version.
My environment:
- macOS 12.4 (21F79) Apple M1 Pro
- ruby 2.6.5p114 (2019-10-01 revision 67812) [-darwin21]
- Rails 5.2.8
- node v12.22.12
- yarn 1.22.19
- @rails/webpacker@^4.0.7
- node-sass “^4.12.0”
Reference
Node.js: Python not found exception due to node-sass and node-gyp
Apple Silicon / arm64 / M1 compatibility? · Issue #259 · pmmmwh/react-refresh-webpack-plugin