Fail to deploy after meteor update: binding.gyp not found

My app fails to deploy (on heroku) after updating meteor. The error messages are:

remote: > node-gyp rebuild
remote: gyp: binding.gyp not found (cwd: /tmp/build_771cd90e/node_modules/node-addon-api) while trying to load binding.gyp
remote: gyp ERR! configure error
remote: gyp ERR! stack Error: gyp failed with exit code: 1
remote: gyp ERR! stack at ChildProcess.onCpExit (/tmp/codon/tmp/cache/meteor/.meteor/packages/meteor-tool/.1.5.1.puot9a++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/node-gyp/lib/configure.js:336:16)
remote: gyp ERR! stack at emitTwo (events.js:87:13)
remote: gyp ERR! stack at ChildProcess.emit (events.js:172:7)
remote: gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:12)
remote: gyp ERR! System Linux 4.4.0-1097-aws
remote: gyp ERR! command “/tmp/codon/tmp/cache/meteor/.meteor/packages/meteor-tool/.1.5.1.puot9a++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node” “/tmp/codon/tmp/cache/meteor/.meteor/packages/meteor-tool/.1.5.1.puot9a++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
remote: gyp ERR! cwd /tmp/build_771cd90e/node_modules/node-addon-api
remote: gyp ERR! node -v v4.8.4
remote: gyp ERR! node-gyp -v v3.6.0
remote: gyp ERR! not ok

and then:

remote: npm WARN In meteor-node-stubs@0.3.3 replacing bundled version of inherits with inherits@2.0.3
remote: npm WARN In meteor-node-stubs@0.3.3 replacing bundled version of readable-stream with readable-stream@2.3.5
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! node-addon-api@3.2.1 install: node-gyp rebuild
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the node-addon-api@3.2.1 install script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /app/.npm/_logs/2021-11-07T18_19_42_259Z-debug.log
remote: ! Push rejected, failed to compile Node.js app.

Can someone please help me? Thanks

What lockVersion are you using in your package-lock.json file? I recently had issues with my deployment coming from bycrpt (also a error with node-gyp). I found that I was using lockVersion 2 (coming from npm version >= 7) so I reinstalled everything with npm 6 and then my deployment was working like a charm.

Thanks a lot for replying.
The package-lock.json says “lockfileVersion”: 1
I am at a loss because I basically let meteor update itself, so I have no idea where to start…

Node-gyp is a cross platform compiler that requires GCC, so first update the system compiler, add gcc and clang packages or whatever your distro supports and give it a whirl, the problem is node-gyp cannot compile. Try compiling the package directly on the machine with npm install node-gyp just in a blank directory and see what it throws you, you can find more on the npm page. Don’t worry this is a npm thing not a meteor thing.

The error is at the top of the output - gyp: binding.gyp not found (cwd: /tmp/build_771cd90e/node_modules/node-addon-api) while trying to load binding.gyp

So basically in short - the build failed, this is commonly due to something on the OS not being there. Like the C libs to actually build with. Run gcc --version to check if GCC is installed.

Guide for ubuntu here -

You can find guides for your distro to add GCC it’s an easy and common task.

Thank you, truedon your help is appreciated.
I am at a loss why I would need gcc for my app. It must be some kind of dependency beyond my grasp.
This is a meteor app. It runs locally without problem. It is at the time of deploying to heroku that it fails.

It’s dependency required by a npm module to compile a required include. My guess would be an encryption library like bcrypt or similar as I have run into this before numerous times.

It’s a totally standard thing, all the major Linux distributions come with a package for compiling C/C++ as that’s what the majority of OS packages are written in. If you used your own server you’d have it fixed in no time, but because you are using a cloud service that obfuscated standard features your hands have possibly been tied. Sadly that’s the way the new generation do stuff.

You could install a instance for $5 on digital ocean and have it up and running in a hour if you’d like. This is why I never ever use a SaaS and own my servers. So no one can dictate the stack… when you use cloud servers it’s a bit like using a public library computer or something, you don’t get full control.

Maybe ask heroku support how to get shell access to add gcc

I’ll try to rebuild my project from scratch. Meteor is like a black box to me, so I may have mixed up when experimenting and ended up with unnecessary packages.

You don’t need to do anything to your app, it’s just the below on terminal just install gcc on a Linux

sudo apt updatesudo apt install build-essential