Closed S1nPur1ty closed 10 months ago
I'm facing the same issue, which could be related to ARM M1 Chips!
Same here. Maybe this would help? https://github.com/Automattic/node-canvas/issues/1733
I just wanted to use blurHash on some images, this is waaaay too deep of a rabbit hole for me to go through just for that 😄
I use macOS Monterey 12.4,I have been troubled in the same issue all day ,trying to find an solution here and there ,but nothing works and cause some new problems came out, and finally i decide to follow the readme tutorial "npm install --build-from-source" and it works. I believe there are something wrong with npm when you trying to use npm command to download the released assets in this repository, according to the log in my terminal , the url was incorrect .then i download it manually , npm run build ,it Error like this:/node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')),apparently this problem is about the architecture ,so i just decide to install dependencies and use "--build-from-source" method . so happy it works.
We have come across this this morning, you get a 404 because the release it's trying to fetch doesn't exist:
https://github.com/Automattic/node-canvas/releases/download/v2.9.3/canvas-v2.9.3-node-v93-darwin-unknown-arm64.tar.gz
vs
https://github.com/Automattic/node-canvas/releases/download/v2.9.3/canvas-v2.9.3-node-v93-darwin-unknown-x64.tar.gz
The path is determined by the entry in the package json:
"binary": {
"module_name": "canvas",
"module_path": "build/Release",
"host": "https://github.com/Automattic/node-canvas/releases/download/",
"remote_path": "v{version}",
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{libc}-{arch}.tar.gz"
},
If all of the prebuilds are x64
for the arch, then you could possibly get away with just using x64
instead of arch
EDIT: The fallback build fails unless you have some deps installed, as found here: https://github.com/Automattic/node-canvas/issues/913#issuecomment-1197420000
brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman
If you tried everything else from the above solutions and still failed, I solved by doing the following:
# update `node-gyp` to the latest version
npm explore npm/node_modules/@npmcli/run-script -g -- npm_config_global=false npm install node-gyp@latest
# re-add it globally for Yarn
yarn global add node-gyp@latest
# then re-install the `canvas` package
yarn add -D canvas
That solution worked on my Mac running on MacOS Ventura 13.2.1
.
Rationale:
I focused on the node-gyp
error and discovered that an old version was being used, so I found a thread in which they suggested to upgrade it, and it worked. Hope it can help someone else!
I had a similar problem, tried various ways. Finally @Codex- 's solution worked for me after running
brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman
https://github.com/Automattic/node-canvas/issues/2078#issuecomment-1201727128
I did try everything mentioned above, I am still getting 404.
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-v115-darwin-unknown-arm64.tar.gz
Here's the complete log:
warning Workspaces can only be enabled in private projects.
[5/6] 🔨 Building fresh packages...
[8/39] ⢀ pulsar-client
[7/39] ⢀ unix-dgram
[3/39] ⢀ fsevents
[4/39] ⢀ canvas
error /Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build --update-binary
Arguments:
Directory: /Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.11
node-pre-gyp info using node@20.14.0 | darwin | arm64
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v115-darwin-unknown-arm64.tar.gz
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-v115-darwin-unknown-arm64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@20.14.0 (node-v115 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v115-darwin-unknown-arm64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@20.14.0 | darwin | arm64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@20.14.0 | darwin | arm64
gyp info find Python using Python version 3.12.3 found at "/opt/homebrew/opt/python@3.12/bin/python3.12"
gyp info spawn /opt/homebrew/opt/python@3.12/bin/python3.12
gyp info spawn args [
gyp info spawn args '/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/faran.shaikh/Library/Caches/node-gyp/20.14.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/faran.shaikh/Library/Caches/node-gyp/20.14.0',
gyp info spawn args '-Dnode_gyp_dir=/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/faran.shaikh/Library/Caches/node-gyp/20.14.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
File "/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
import gyp # noqa: E402
^^^^^^^^^^
File "/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module>
import gyp.input
File "/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
from distutils.version import StrictVersion
ModuleNotFoundError: No module named 'distutils'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/lib/configure.js:325:16)
gyp ERR! stack at ChildProcess.emit (node:events:519:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Darwin 23.5.0
gyp ERR! command "/Users/faran.shaikh/.nvm/versions/node/v20.14.0/bin/node" "/Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas/build/Release" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v115"
gyp ERR! cwd /Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas
gyp ERR! node -v v20.14.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/faran.shaikh/.nvm/versions/node/v20.14.0/bin/node /Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v115' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/faran.shaikh/Documents/code/Sculptor/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack at ChildProcess.emit (node:events:519:28)
node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1105:16)
node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:305:5)
node-pre-gyp ERR! System Darwin 23.5.0
node-pre-gyp ERR! command "/Users/faran.shaikh/.nvm/versions/node/v20.14.0/bin/node" "/Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
node-pre-gyp ERR! cwd /Users/faran.shaikh/Documents/code/Sculptor/node_modules/canvas
node-pre-gyp ERR! node -v v20.14.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.11
node-pre-gyp ERR! not ok
Failed to execute '/Users/faran.shaikh/.nvm/versions/node/v20.14.0/bin/node /Users/faran.shaikh/Documents/code/Sculptor/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/Users/faran.shaikh/Documents/c
for anyone facing this issue, try use python 3.10.0, use pyenv, and set global to 3.10.0
(it must be 3.10.0
, 3.10.14
does not work).
Is anyone able to install node-canvas? When using npm i -S canvas or yarn add canvas, I get to see the following issue (notice the url with the text unknown --> https://github.com/Automattic/node-canvas/releases/download/v2.9.3/canvas-v2.9.3-node-v102-darwin-unknown-arm64.tar.gz ):