javascriptnode.jsherokunode-canvas

Getting "Permission Denied" when trying to install node.js canvas on Heroku


i am using canvas package for node.js

it works fine on my pc but whenever i deploy it to heroku i always get an error here is what i get

remote: -----> Installing dependencies
remote:        Prebuild detected (node_modules already exists)
remote:        Rebuilding any native modules
remote:
remote:        > canvas@2.6.1 install /tmp/build_f373ac33/node_modules/canvas
remote:        > node-pre-gyp install --fallback-to-build
remote:
remote:        sh: 1: node-pre-gyp: Permission denied
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno 126
remote:        npm ERR! canvas@2.6.1 install: `node-pre-gyp install --fallback-to-build`
remote:        npm ERR! Exit status 126
remote:        npm ERR!
remote:        npm ERR! Failed at the canvas@2.6.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!     /tmp/npmcache.bcUNy/_logs/2020-08-06T17_57_03_074Z-debug.log
remote:
remote: -----> Build failed

i tried this tutorial but it didnt work https://github.com/Automattic/node-canvas/wiki/Installation%3A-Heroku

here's my package.json

  "name": "asta-bot",
  "version": "1.0.0",
  "description": "a discord bot",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "keywords": [
    "hello"
  ],
  "engines": {
    "node": "13.3.x",
    "npm": "*"
  },
  "author": "reuben chagas fernandes",
  "license": "ISC",
  "dependencies": {
    "cleverbot-node": "^0.3.11",
    "decode-encode-binary": "^1.4.9",
    "didyoumean": "^1.2.1",
    "discord.js": "^12.2.0",
    "express": "^4.17.1",
    "ffmpeg": "^0.0.4",
    "google-tts-api": "0.0.4",
    "mal-scraper": "^2.7.1",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.31",
    "nodemon": "^2.0.2",
    "opusscript": "^0.0.7",
    "pg": "^8.0.2",
    "request": "^2.88.2",
    "simple-youtube-api": "^5.2.1",
    "translate": "^1.1.2",
    "trivia-api": "^1.0.1",
    "urban-dictionary": "^2.2.1",
    "weather-js": "^2.0.0",
    "wikifakt": "^1.0.3",
    "wikijs": "^6.0.1",
    "youtube-search": "^1.1.4",
    "ytdl-core": "^2.0.1"
  }
}```

Solution

  • well some versions of node-canvas dont work on heroku the canvas version im using is 2.6.1 and node version is 13.3.0

    the build fails on other node version it works perfectly on 13.3.0