error /node_modules/node-sass: Command failed
I had the same problem and I solved with the steps:
- if your are on Apple M1 Chip, run terminal with
Rosetta 2
(optional, only necessary if you have the Node installed with Rosetta) - check your
node-sass
version in yourpackage.json
and compare with the following table:
NodeJS | Supported node-sass version | Node Module |
---|---|---|
Node 16 | 6.0+ | 93 |
Node 15 | 5.0+ | 88 |
Node 14 | 4.14+ | 83 |
Node 13 | 4.13+, <5.0 | 79 |
Node 12 | 4.12+ | 72 |
Node 11 | 4.10+, <5.0 | 67 |
Node 10 | 4.9+, <6.0 | 64 |
Node 8 | 4.5.3+, <5.0 | 57 |
Node <8 | <5.0 | <57 |
- install the Nodejs version according with your
node-sass
- clean old node_modules with:
rm -rf node_modules
- run:
npm install
Resource:
I am running Rails 6
and for some reason it was pulling webpacker 4.3.0
which was pulling node-sass 4.3.0
rather than 6.0.0
which is the latest as of the date of this post.
What worked for me is the following:
- Deleting the
node_module
folder,package-lock.json
andyarn.lock
- In my
package.json
, I upgradedrails/webpacker: 5.3.0
. - I then re-ran
yarn install
. - Then I ran
yarn add node-sass
That worked like a charm, after trying everything else above.
I believe those were the exact steps, although to be honest I have been trying sooo many things and they didn't work and I finally got it to work so there is a possibility I may have missed a step, but I did my best to re-create it for any future frustrated soul out there.