Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install node-canvas because of the broken uri #2078

Closed
S1nPur1ty opened this issue Jul 17, 2022 · 8 comments
Closed

Can't install node-canvas because of the broken uri #2078

S1nPur1ty opened this issue Jul 17, 2022 · 8 comments

Comments

@S1nPur1ty
Copy link

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 ):

➜  hashlips_art_engine git:(main) ✗ yarn add canvas   
yarn add v1.22.19
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
error /Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build --update-binary
Arguments: 
Directory: /Users/s1npur1ty/Development/blockchain/hashlips_art_engine/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.9
node-pre-gyp info using node@17.0.0 | darwin | arm64
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.3/canvas-v2.9.3-node-v102-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.9.3/canvas-v2.9.3-node-v102-darwin-unknown-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.9.3 and node@17.0.0 (node-v102 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.9.3/canvas-v2.9.3-node-v102-darwin-unknown-arm64.tar.gz 
gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@17.0.0 | darwin | arm64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@17.0.0 | darwin | arm64
gyp info find Python using Python version 3.9.13 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
gyp info spawn /opt/homebrew/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/Users/s1npur1ty/.nvm/versions/node/v17.0.0/lib/node_modules/npm/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/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/s1npur1ty/.nvm/versions/node/v17.0.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/s1npur1ty/Library/Caches/node-gyp/17.0.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/s1npur1ty/Library/Caches/node-gyp/17.0.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/s1npur1ty/.nvm/versions/node/v17.0.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/s1npur1ty/Library/Caches/node-gyp/17.0.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/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 ]
Package pangocairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `pangocairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pangocairo' found
gyp: Call to 'pkg-config pangocairo --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/s1npur1ty/.nvm/versions/node/v17.0.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:353:16)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/Users/s1npur1ty/.nvm/versions/node/v17.0.0/bin/node" "/Users/s1npur1ty/.nvm/versions/node/v17.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v102"
gyp ERR! cwd /Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas
gyp ERR! node -v v17.0.0
gyp ERR! node-gyp -v v8.2.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/Users/s1npur1ty/.nvm/versions/node/v17.0.0/bin/node /Users/s1npur1ty/.nvm/versions/node/v17.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1062:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
node-pre-gyp ERR! System Darwin 21.4.0
node-pre-gyp ERR! command "/Users/s1npur1ty/.nvm/versions/node/v17.0.0/bin/node" "/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
node-pre-gyp ERR! cwd /Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas
node-pre-gyp ERR! node -v v17.0.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.9
node-pre-gyp ERR! not ok 
Failed to execute '/Users/s1npur1ty/.nvm/versions/node/v17.0.0/bin/node /Users/s1npur1ty/.nvm/versions/node/v17.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/s1npur1ty/Development/blockchain/hashlips_art_engine/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (1)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
@colo-o
Copy link

colo-o commented Jul 18, 2022

I'm facing the same issue, which could be related to ARM M1 Chips!

@ovsw
Copy link

ovsw commented Jul 20, 2022

Same here. Maybe this would help? #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 😄

@MetaverseMan
Copy link

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.

@Codex-
Copy link

Codex- commented Aug 1, 2022

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: #913 (comment)

brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

@rstagi
Copy link

rstagi commented Mar 7, 2023

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!

@foysal-m
Copy link

foysal-m commented Apr 8, 2024

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
#2078 (comment)

@faran4iqvia
Copy link

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

@shuweili1122
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants