Warning: slightly cheeky post, I have the highest respect for the people behind node-gyp. They’re way smarter than me.

If you’ve been working with Node for a while, surely you’ve encountered issues with node-gyp. Searching for the solution can be a frustrating experience. Things get very technical and all kinds of solutions are offered. This is what always works for me.

What is node-gyp?

I won’t get into the details, because I’m not really bothered with understanding it. I just want it to work so I can focus on writing code for my clients. They’re not paying me to fiddle with node-gyp after all.

Node-gyp is a tool to compile native add-ons for Node.js. Normally, you’ll write Javascript code and Node.js runs it on the V8 engine. All is well.

But some libraries need native capabilities. And native means different on different platforms (Windows, Mac, Linux,…). Node-gyp allows library authors to compile their Node.js add-ons to the platform you’re running.

When Things Go Wrong

Sometimes you get errors with node-gyp. Out of the blue, it stops working. Reinstalling node_modules no longer works. Or it works, but then when you run the application, you encounter errors about bindings not being found.

Why does this happen? No idea. As I said, this is a bit too deeply technical for me.

But this is what works as solution.

The Solution (for Me)

npm i -g node-gyp
npm ci

That’s basically it. Reinstall node-gyp globally and then reinstall your node modules.

No “node-gyp rebuild” nonsense. Now get back to work!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.