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

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

remote: > node-gyp rebuild
remote:
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:
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 - https://linuxize.com/post/how-to-install-gcc-compiler-on-ubuntu-18-04/

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

Thanks.
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

@truedon
I am running into a similar issue, but my build essentials seem installed on my production box.

I made a very small mod to an app i deploy to production but it no longer npm installs on production. But the previous tar file still does install on production!

the previous version tar when I npm install says

> bcrypt@3.0.8 install /var/www/ff/bundle/programs/server/npm/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.8/bcrypt_lib-v3.0.8-node-v83-linux-x64-glibc.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.8 and node@14.19.3 (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
make: Entering directory '/var/www/ff/bundle/programs/server/npm/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
(then after a few warnings it works)

but the new version instead says…

> bcrypt@3.0.8 install /var/www/ff/redo/bundle/programs/server/npm/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module '../'
Require stack:
- /var/www/ff/redo/bundle/programs/server/npm/node_modules/.bin/node-pre-gyp
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/var/www/ff/redo/bundle/programs/server/npm/node_modules/.bin/node-pre-gyp:15:20)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/www/ff/redo/bundle/programs/server/npm/node_modules/.bin/node-pre-gyp'
  ]
}
npm ERR! code ELIFECYCLE

Thinking it might be some code I changed in the new version, I checked out the old version of the tar that works and rebuilt and deployed it, and even the new build deploy of the old version fails the same way.

When i take the previous tar of the old version which I built in December, it then installs and makes correctly. ??!!??

There seems to be some differences between the tar from my December build and my current build. It is a new dev server, so the dev server packages must be different, but don’t know what is missing on my new dev box.

I am on Meteor 2.7.3

Node-pre-gyp was deprecated in 2021 more info below:

On Feb 9th, 2021 @mapbox/node-pre-gyp@1.0.0 was released. Older, unscoped versions that are not part of the @mapbox org are deprecated and only @mapbox/node-pre-gyp will see updates going forward. To upgrade to the new package do:

npm uninstall node-pre-gyp --save
npm install @mapbox/node-pre-gyp --save

The problem is your node-pre-gyp it’s been deprecated so it’s not building - you need to have it to build the C code for the bcrypt to not have to run in JS