GYP ERR! build error. stack Error: 'make' failed with exit code 2

gyp err! build error yarn
gyp err! stack error: `gyp` failed with exit code: 1
update node-gyp
node-gyp rebuild error mac
gyp err! stack error: not found: make
node-gyp rebuild error windows 10
exec gyp err stack error command failed
node-gyp build dependencies

I am currently working on a nodejs web application I am having trouble pushing the application online with cloud foundry. I did some research on the errors and it seems that maybe some of the packages being installed have some conflicts.

This is the package.json file.

{
  "dependencies": {
    "c3": "^0.4.12",
    "cfenv": "1.0.0",
    "cloudant": "^1.8.0",
    "dygraphs": "^2.0.0",
    "express": "4.5.1",
    "getmac": "1.0.6",
    "http": "0.0.0",
    "mqtt": "1.0.5",
    "properties": "1.2.1",
    "save": "^2.3.0",
    "sockjs": "0.3.9",
    "websocket-multiplex": "0.1.x"
  },
  "description": "description.",
  "license": "UNLICENSED",
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "<gitUrl>"
  }
}

This is the error I encounter when I try to push the application via cloud foundry. This similar error happens when I npm install after deleting all the content of the node_modules folder.

../src/bufferutil.cc:32:50: error: call of overloaded 'NODE_SET_METHOD(v8::Local<v8::FunctionTemplate>&, const char [6], void (&)(const v8::FunctionCallbackInfo<v8::Value>&))' is ambiguous
     NODE_SET_METHOD(t, "merge", BufferUtil::Merge);

../src/bufferutil.cc:32:50: note: candidates are:
In file included from ../src/bufferutil.cc:8:0:
/root/.node-gyp/8.0.0/include/node/node.h:257:13: note: void node::NODE_SET_METHOD(v8::Local<v8::Template>, const char*, v8::FunctionCallback)
 inline void NODE_SET_METHOD(v8::Local<v8::Template> recv,
             ^
/root/.node-gyp/8.0.0/include/node/node.h:270:13: note: void node::NODE_SET_METHOD(v8::Local<v8::Object>, const char*, v8::FunctionCallback)
 inline void NODE_SET_METHOD(v8::Local<v8::Object> recv,
             ^
bufferutil.target.mk:95: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
make: Leaving directory '/home/WibiSmart-Bluemix-App/node_modules/bufferutil/build'

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

Did anyone else encounter this issue, or knows how to fix it?

It worked after deleting package-lock.json and re run npm install

If you are using yarn to build your program delete yarn.lock and re run yarn install

trying to 'npm install', getting node-gyp rebuild errors · Issue #809 , gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:262:23) gyp ERR! I am trying to npm install my packages, and it seems a package named protagonist needs node-gyp I have literally tried everything I found online (issues here included) and still cant solve this. 2 days I have spent searching around, chan

Figured out the issue. Some of the npm packages were not up to date. I modified the package.json to install all the latest versions of all packages and the error was fixed.

gyp ERR! build error · Issue #983 · nodejs/node-gyp · GitHub, It worked after deleting package-lock.json and re run npm install. If you are using yarn to build your program delete yarn.lock and re run yarn  gyp ERR! stack at ChildProcess.onExit (E:\Dev odejs\installationdir ode_modules pm ode_modules ode-gyp\lib\build.js:194:23) gyp ERR! stack at ChildProcess.emit (events.js:210:5) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) gyp ERR! System Windows_NT 10.0.18363

Delete the ~/.node-gyp folder and then the ~/.npmrc file.

Reboot your server and rerun npm install in your project folder

Edit:

Warning: removing ~/.npmrc will delete your other configurations

GYP ERR! build error. stack Error: 'make' failed with exit code 2 , 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. Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.

For other people that stumble into this exact problem:

In my case, the server node version was set to an older version in my package.json file than what my local environment was running. So check what you are running locally with:

node --version
-> 8.11.3

Then look at your server setting in your package.json:

{
  "name": "myapp",
  "version": "0.0.0",
  "private": true,
  "engines": {
    "node": "7.10.2" // <-- This is too old, set it to the node version you are running locally (8.11.3)
  },

I hope this helps someone.

Debugging “Make Failed with Exit Code 2” Error, Got the same problem. gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess. A node-gyp error means that a native module has failed to build. IMHO there has never been one single answer that has directly solved this issue in my experience. However below is a checklist I would suggest to follow if anyone else comes across node-gyp errors. You may have already tried these but just leaving it for reference.

This has been old yet consistent issue well documented at: https://github.com/nodejs/node-gyp/issues/809

For me the error mentioned the version numbers like:

gyp ERR! System Darwin 17.7.0
gyp ERR! node -v v12.1.0
gyp ERR! node-gyp -v v3.8.0

After attempting all the possible combinations of solutions (modify ~/.npmrc, remove ~/.node-gyp, clear the npm cache, delete node_modules and even restart the system), what worked with me was downgrading the node.

I believe the versions mentioned in the log for node and node-gyp are incompatible. So I reverted to an older node version which worked like a charm.

npm install -g node@11.10.0

There should be a clear documentation describing breaking changes and compatibility issues between the two.

node gyp rebuild fails on install, gyp ERR! build error gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe  I get this when I install msvs_version=2012 'npm WARN package.json fs@0.0.2 No repository field. npm WARN package.json fs@0.0.2 No README data npm WARN package.json node-java@1.0.1 No repository field. npm WARN package.json node-java@1.0.1 No README data npm WARN package.json path@0.11.14 path is also the name of a node core module. npm WARN prefer global node-gyp@1.0.3 should be installed

I am getting the below error when I am running ./watch command on , make: Leaving directory '/home/rishabh/customer-management-api/​node_modules/couchbase/build' gyp ERR! build error gyp ERR! stack  The issue is caused because Node can’t find the Python path on your system.. Solution (optional) Install Python from the official website. Run the following command to install the Windows Build Tools using an elevated (Administrator) terminal window which installs the VS Build Tools and also Python 2.7:

Gyp ERR! stack Error: `make` failed with exit code: 2, .. gyp ERR! build error. gyp ERR! stack Error: `make` failed with exit code: 2. gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe` failed with exit code: 1 #193 Open thisTom opened this issue Aug 19, 2019 · 6 comments

ca-apm-probe Gyp Build Installation Error - TechDocs, dir "/opt/plcnext/appshome/data/60002172000051/lib/node_modules/bcrypt/.​node-gyp" gyp ERR! build error gyp ERR! stack Error: not found:  trying to 'npm install', getting node-gyp rebuild errors #809. sunnee5150 opened this issue on Nov 8, 2015 · 251 comments. trying to 'npm install', getting node-gyp rebuild errors #809. sunnee5150 opened this issue on Nov 8, 2015 · 251 comments. sunnee5150 commented on Nov 8, 2015. ernestscomputer:musicomp ernest son$ npm install

Comments
  • Whenever you encounter such errors, the actual error(s) will appear before these lines you've currently posted in the console.
  • @mscdex I added the lines of code I am getting before the error
  • Does switching to node v6 help?
  • @opiethehokie What would be the command to do so? It seems to me that the bufferutil comes up a lot, would anyone know what that is?
  • What is your compiler and compiler version?
  • I hate it when this is the solution
  • This worked for. In my case it was yarn.lock file which I had to delete.
  • yes.. if you use yarn to build instead of npm. I'll update my answer.. thank you
  • how to do that ?
  • This worked for me. Was having issues with sharp dependency on the gatsby-starter-netlify-cms.
  • Warning: removing ~/.npmrc will delete your other configurations, for example your default author name.
  • Good to know @PaulBerg
  • This solved it for me. Downgraded from Node 10 to Node 8 and got my repo running locally.