DEV Community

Andrzej Krzywda
Andrzej Krzywda

Posted on

Fixing the node-sass problem in Rails - node downgrade helps

Today I've had one of those irritating problems with Rails that I know one day I will have again. So, future me when you google it, here is the fix, you're welcome :)

The problem shows like this during rails new new_app

node_modules/node-sass: Command failed.
Enter fullscreen mode Exit fullscreen mode

and

1 error generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/andrzej/apps/stimulus_infinite_scroll/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/Cellar/node/16.0.0/bin/node" "/Users/andrzej/apps/stimulus_infinite_scroll/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/andrzej/apps/stimulus_infinite_scroll/node_modules/node-sass
gyp ERR! node -v v16.0.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Enter fullscreen mode Exit fullscreen mode

As you can see, the node version used is 16.0.0. At the moment of writing this post, it's a relatively new version and not everything works fine with this.

The solution? Downgrade node.

In my case I did:

npm install -g n
sudo n 14
Enter fullscreen mode Exit fullscreen mode

and that's it.

A possible alternative:

brew remove node
brew install node@14
Enter fullscreen mode Exit fullscreen mode

If this helped you, let me know in the comments, so that I believe in value of such posts even more ;)

Discussion (3)

Collapse
linktoming profile image
Mingming Wang

This saved my day. Thanks!

Collapse
saronyitbarek profile image
Saron

Saved my day too, thank you!!

Collapse
yetiskier profile image
yetiskier

So good, so simple, worked for me.
Thanks