How to run node-canvas on heroku?

Viewed 378

I've created a discord bot with node.js that uses a npm called canvas which is running version 2.6.1 but when I wen't to push my files to github and deploy I keep getting faced with errors. If this helps I'm running one buildpack which is the default node.js one.

I've tried using a buildpack that you can find here: https://github.com/Automattic/node-canvas/wiki/Installation:-Heroku but that doesn't work.

-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 12.x...
       Downloading and installing node 12.18.3
       Using default npm version: 6.14.6
       
-----> Installing dependencies
       Prebuild detected (node_modules already exists)
       Rebuilding any native modules
       
       > canvas@2.6.1 install /tmp/build_3c59f676_/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.AGHnL/_logs/2020-08-11T12_04_57_845Z-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

Any reason to this and how I can fix this? I've been struggling on this for around an hour or so now.

0 Answers
Related