Solve node-gyp compatibility issues in npm install

I had to reinstall a project built in Keystone.js – a JavaScript CMS – lately, and I encountered some compatibility issues that I encountered before. I totally forgot about it, and took me a while to realize it was the same issues I encountered before.

Mainly, the issue was node-gyp. Node-gyp is a command-line tool written in Node.js for compiling addon modules for Node.js. It bundles Chrome’s team’s gyp project, which helps with cross-platform issues. Alas, the tool itself ended up causing its own issues!

Node-gyp error
The error message

For me, there are two problem:

  1. It does not support Python 3.
  2. It needs make – a build automation tool – with its variable CXX set to proper C/C++ compiler toolchain.

In my case, my system’s default Python is 3 and the CXX is not always set to the right toolchain. So, first remove the local directory’s node_modules folder if you did a failedĀ npm install earlier, then input this in the command line:

CXX=c++ npm install –python=python2.7

Most node-gyp rebuild error should disappear!

KeystoneJS success
Dadah!!! Keystone.js now running!