【问题标题】:Getting "Permission Denied" when trying to install node.js canvas on Heroku尝试在 Heroku 上安装 node.js 画布时出现“权限被拒绝”
【发布时间】:2020-11-27 01:14:30
【问题描述】:

我正在为 node.js 使用 canvas 包

它在我的电脑上运行良好,但每当我将它部署到 heroku 时,我总是会出错 这是我得到的

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

我试过这个教程,但没有用 https://github.com/Automattic/node-canvas/wiki/Installation%3A-Heroku

这是我的 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"
  }
}```

【问题讨论】:

    标签: javascript node.js heroku node-canvas


    【解决方案1】:

    有些版本的 node-canvas 不能在 heroku 上工作 我使用的画布版本是 2.6.1 节点版本为 13.3.0

    在其他节点版本上构建失败 它在 13.3.0 上完美运行

    【讨论】:

      【解决方案2】:

      试试这个。

      npm config set user 0
      npm config set unsafe-perm true
      

      【讨论】:

      • 我仍然构建失败
      • 请也发布您的 package.json 文件。
      • 这是做什么的?可以补充说明吗
      【解决方案3】:

      在节点 v16 上遇到问题。

      正在安装画布包。

      帮助:安装 node v13 (nvm install 13 && nvm use 13)

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
      • @MD.RAKIBHASAN 我没有使用 Heroku,所以我想我可以增加一点清晰度。
      猜你喜欢
      • 2016-05-11
      • 1970-01-01
      • 2011-05-23
      • 1970-01-01
      • 1970-01-01
      • 2017-11-15
      • 2021-08-29
      • 2016-02-21
      • 2020-05-01
      相关资源
      最近更新 更多