1

我正在为 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"
  }
}```
4

3 回答 3

1

好吧,某些版本的节点画布在 heroku 上不起作用,我使用的画布版本是 2.6.1,节点版本是 13.3.0

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

于 2020-09-06T06:22:18.337 回答
0

在节点 v16 上遇到问题。

正在安装画布包。

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

于 2021-12-21T10:46:51.497 回答
0

尝试这个。

npm config set user 0
npm config set unsafe-perm true
于 2020-08-07T05:46:28.830 回答