node.jsnpmcanvasnpm-install

npm command failed while installing canvas


I'm installing canvas on my raspberry pi 5B. But it failed.

Here is what I got:


berryuki@berryuki:~/items/Bot/salt-bot/external/salt-main $ npm i canvas

npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.

npm WARN deprecated npmlog@5.0.1: This package is no longer supported.

npm WARN deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported

npm WARN deprecated are-we-there-yet@2.0.0: This package is no longer supported.

npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported

npm WARN deprecated gauge@3.0.2: This package is no longer supported.

npm ERR! code 1

npm ERR! path /home/berryuki/items/Bot/salt-bot/node_modules/canvas

npm ERR! command failed

npm ERR! command sh -c node-pre-gyp install --fallback-to-build --update-binary

npm ERR! Failed to execute '/usr/bin/node /usr/share/nodejs/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/home/berryuki/items/Bot/salt-bot/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/berryuki/items/Bot/salt-bot/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)

npm ERR! node-pre-gyp info it worked if it ends with ok

npm ERR! node-pre-gyp info using node-pre-gyp@1.0.11

npm ERR! node-pre-gyp info using node@18.19.0 | linux | arm64

npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-linux-glibc-arm64.tar.gz

npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-linux-glibc-arm64.tar.gz

npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@18.19.0 (node-v108 ABI, glibc) (falling back to source compile with node-gyp)

npm ERR! node-pre-gyp WARN Hit error response 

berryuki@berryuki:~/items/Bot/salt-bot/external/salt-main $ npm i canvas --registry="https://registry.npmjs.org/"

npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.

npm WARN deprecated npmlog@5.0.1: This package is no longer supported.

npm WARN deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported

npm WARN deprecated are-we-there-yet@2.0.0: This package is no longer supported.

npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported

npm WARN deprecated gauge@3.0.2: This package is no longer supported.

npm ERR! code 1

npm ERR! path /home/berryuki/items/Bot/salt-bot/node_modules/canvas

npm ERR! command failed

npm ERR! command sh -c node-pre-gyp install --fallback-to-build --update-binary

npm ERR! Failed to execute '/usr/bin/node /usr/share/nodejs/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/home/berryuki/items/Bot/salt-bot/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/berryuki/items/Bot/salt-bot/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)

npm ERR! node-pre-gyp info it worked if it ends with ok

npm ERR! node-pre-gyp info using node-pre-gyp@1.0.11

npm ERR! node-pre-gyp info using node@18.19.0 | linux | arm64

npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-linux-glibc-arm64.tar.gz

npm ERR! node-pre-gyp ERR! install request to https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-linux-glibc-arm64.tar.gz failed, reason: connect ETIMEDOUT 20.205.243.166:443

npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@18.19.0 (node-v108 ABI, glibc) (falling back to sourc

By default I change the npm registry. After that I suspected that the registry might be the problem, so I change back to official registry. But that seemed not working.

OS: enter image description here version of node: 18.19.0 version of npm: 9.2.0


Solution

  • prebuild binaries for arm aren't available for canvas:

    https://github.com/Automattic/node-canvas/wiki#installation-guides

    If you're running ubuntu/debian try this first:

    sudo apt-get update 
    sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev