0

I have a discord.js bot and it runs on Heroku. I added canvas just now, and now the bot is failing to build.

This is the log:

-----> Installing dependencies
       Prebuild detected (node_modules already exists)
       Rebuilding any native modules
       
       > canvas@2.6.1 install /tmp/build_c8ad4f45_/node_modules/canvas
       > node-pre-gyp install --fallback-to-build
       
       sh: 1: node-pre-gyp: Permission denied
       npm ERR! code ELIFECYCLE
       npm ERR! errno 126
       npm ERR! canvas@2.6.1 install: `node-pre-gyp install --fallback-to-build`
       npm ERR! Exit status 126
       npm ERR! 
       npm ERR! Failed at the canvas@2.6.1 install script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.uZg6i/_logs/2021-01-01T17_53_37_239Z-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:
       
       - node_modules checked into source control
         https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

I already installed node-pre-gyp as the log suggested, and nothing changed. Here is package.json:

{
  "dependencies": {
    "canvas": "^2.6.1",
    "discord.js": "^12.4.1",
    "dotenv": "^8.2.0",
    "firebase": "^8.1.1",
    "firebase-admin": "^9.4.1",
    "node-pre-gyp": "^0.11.0"
  }
}

Does anyone know a solution to this?

  • Issues with `node-pre-gyp` are often associated with tracked `node_modules/` directories. Have you committed and pushed that directory to Heroku? It looks like maybe you did: "Prebuild detected (node_modules already exists)". – ChrisGPT was on strike Jan 01 '21 at 18:34
  • Yes, its all pushed and committed, I even tried reinstalling all the packages, still the same issue EDIT: I dont have a gitignore on node_modules, might try doing that – BackspaceRGB Jan 01 '21 at 18:46
  • Okay, that's likely the problem. Your `node_modules/` (probably) shouldn't be tracked at all. Let Heroku install dependencies itself. `git rm -r --cached node_modules/`, add `node_modules` to your `.gitignore`, then commit, and push again. – ChrisGPT was on strike Jan 01 '21 at 18:51
  • This could also be a Node.js version mismatch. What version of Node.js are you developing with locally? [Add that to your `package.json`'s `engines`](https://stackoverflow.com/a/56562466/354577). – ChrisGPT was on strike Jan 01 '21 at 18:54
  • Does this answer your question? [Heroku build failing on dependency install](https://stackoverflow.com/questions/62599213/heroku-build-failing-on-dependency-install) – ChrisGPT was on strike Jan 01 '21 at 18:54
  • I added the ```.gitignore``` file, added ```node_modules``` to it, still says Build Failed. Am I doing something wrong? – BackspaceRGB Jan 01 '21 at 18:55
  • The issues is that when I did ```node --version```, I get 15.0.1, but from the other topic it seems like that version doesnt work, so I did ```14.14.0``` in engines, still Build Failed EDIT: I put 15.0.1 in engines, app deploys, bot doesnt go online – BackspaceRGB Jan 01 '21 at 19:00
  • Your "bot doesn't go online" issue is a completely different issue. Please don't ask new questions in the comments. – ChrisGPT was on strike Jan 01 '21 at 19:04
  • Ok so apparently requiring canvas crashes the bot :/ – BackspaceRGB Jan 01 '21 at 19:12

0 Answers0