Top 5 node frameworks

Debugging “Make Failed with Exit Code 2” Error

The “Make Failed with Exit Code 2” error occurs during the node modules installation. We see lots of stack trace including the one shown below.

gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:285:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Linux 4.4.30-ti-r64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/WibiSmart-Bluemix-App/node_modules/bufferutil
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.6.1
gyp ERR! not ok

The reason behind this error is not singular. Make sure you have latest Node and npm installed in your system.

Also, make sure build essentials is installed in your system.

Let’s try to debug and fix it.

Debug #1: Deleting package-lock.json file

Try to remove the package-lock.json file and remove node modules folder too. Then re-install the modules.

rm -rf package-lock.json
rm -rf node_modules

Then re-install the modules.

npm install

This should fix the error.

Debug #2: Deleting .node-gyp folder

Delete the .node-gyp folder that should be present in your home directory.

rm -rf ~/.node-gyp

Then re-install the modules.

npm install

Debug #3: Re-install node-gyp

Try re-installing node-gyp again.

npm i -g node-gyp

You may require sudo access depending upon your node installation.

Debug #4: Update Node and NPM

The old version of Node and NPM can also cause this issue. Re-install it with build modules and check if it works. You can also re-install node modules using NPM.

Debug #5: Install build essentials

Try installing/re-installing build essentials packages. Find the command below for Ubuntu operating system.

sudo apt-get install -y build-essential

Let me know if you have solved it using any other methods. I’ll add it in the list.

Shahid

Founder of Codeforgeek. Technologist. Published Author. Engineer. Content Creator. Teaching Everything I learn!

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

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