Heroku build suddenly failing

I have spent hours trying to resolve.

Heroku logs only hint is:

Installing dependencies
Installing node modules (package.json + package-lock)
npm ERR! cb.apply is not a function

yet, there is no cb.apply in either file.

Has anyone else had - and recovered from an error such as this?

~Elle

1 Like

Hi Elle,

Maybe this is a Heroku problem? try contacting their support see if they can find more info about the problem.

I am currently experiencing the exact same thing trying to push my node.js app to Heroku. I have seemingly changed nothing personally that would have caused this.

I’ll reply here if I happen to find a resolution. I would very much appreciate if anyone else could do the same

What my heroku log looked like was this:

-----> Building on the Heroku-22 stack
-----> Using buildpacks:
       1. heroku/nodejs
       2. https://github.com/jontewks/puppeteer-heroku-buildpack.git
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  >=14.15.0
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version >=14.15.0...
       Downloading and installing node 20.7.0...
       Detected package-lock.json: defaulting npm to version 5.x.x
       Bootstrapping npm 5.x.x (replacing 10.1.0)...
       npm 5.10.0 installed
       
-----> Restoring cache
       Cached directories were not restored due to a change in version of node, npm, yarn or stack
       Module installation may take longer for this build
       
-----> Installing dependencies
       Installing node modules (package.json + package-lock)
       npm ERR! cb.apply is not a function
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.zV13I/_logs/2023-09-21T14_43_04_658Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Dangerous semver range (>) in engines.node
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

What resolved it for me was to go to my package.json and package-lock.json and change the versions under engines. I also updated my local node.js version to the current version.

In my package.json and package-lock.json, engines was:

"engines": {
    "node": ">=14.15.0"
  }

and I updated them both to have:

"engines": {
    "node": ">=20.x",
    "npm": ">=10.x"
  }

Could you get hold of this log file to see the errors there?

Seems they made the node versions specification on Heroku pretty strict… while the version we specify is pretty valid.

Maybe you should pass that as a bug to their support as well.

Followed all suggestions here to no avail.

What did work was running this in CLI:

heroku config:set BUNDLE_WITHOUT=“development:test” -a appName

~Elle