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

Command failed:node-pre-gyp install --fallback-to-build --update-binary #2186

Closed
da-du opened this issue Jan 3, 2023 · 24 comments
Closed

Comments

@da-du
Copy link

da-du commented Jan 3, 2023

Steps to Reproduce

When I run yarn, the error is as follows:

warning Error running install script for optional dependency: "/Users/XXX/project/saas-statistics/node_modules/canvas: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build --update-binary
Arguments: 
Directory: /Users/XXX/project/saas-statistics/node_modules/canvas
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | arm64
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.0/canvas-v2.11.0-node-v93-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.0/canvas-v2.11.0-node-v93-darwin-unknown-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v93 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.0/canvas-v2.11.0-node-v93-darwin-unknown-arm64.tar.gz 
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info find Python using Python version 3.8.9 found at \"/Library/Developer/CommandLineTools/usr/bin/python3\"
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/Users/XXX/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/XXX/project/saas-statistics/node_modules/canvas/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/XXX/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/XXX/Library/Caches/node-gyp/16.19.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/XXX/Library/Caches/node-gyp/16.19.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/XXX/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/XXX/Library/Caches/node-gyp/16.19.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/XXX/project/saas-statistics/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 ]
/bin/sh: pkg-config: command not found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 127 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/XXX/node_modules/node-gyp/lib/configure.js:325:16)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 21.6.0
gyp ERR! command \"/Users/XXX/.nvm/versions/node/v16.19.0/bin/node\" \"/Users/XXX/node_modules/node-gyp/bin/node-gyp.js\" \"configure\" \"--fallback-to-build\" \"--update-binary\" \"--module=/Users/XXX/project/saas-statistics/node_modules/canvas/build/Release/canvas.node\" \"--module_name=canvas\" \"--module_path=/Users/XXX/project/saas-statistics/node_modules/canvas/build/Release\" \"--napi_version=8\" \"--node_abi_napi=napi\" \"--napi_build_version=0\" \"--node_napi_label=node-v93\"
gyp ERR! cwd /Users/XXX/project/saas-statistics/node_modules/canvas
gyp ERR! node -v v16.19.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/Users/XXX/.nvm/versions/node/v16.19.0/bin/node /Users/XXX/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/Users/XXX/project/saas-statistics/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/XXX/project/saas-statistics/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/XXX/project/saas-statistics/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
node-pre-gyp ERR! System Darwin 21.6.0
node-pre-gyp ERR! command \"/Users/XXX/.nvm/versions/node/v16.19.0/bin/node\" \"/Users/XXX/project/saas-statistics/node_modules/canvas/node_modules/.bin/node-pre-gyp\" \"install\" \"--fallback-to-build\" \"--update-binary\"
node-pre-gyp ERR! cwd /Users/XXX/project/saas-statistics/node_modules/canvas
node-pre-gyp ERR! node -v v16.19.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.10
node-pre-gyp ERR! not ok 
Failed to execute '/Users/XXX/.nvm/versions/node/v16.19.0/bin/node /Users/XXX/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/Users/XXX/project/saas-statistics/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/XXX
[5/5] ♻️  Cleaning modules...
success Saved lockfile.
✨  Done in 94.91s.

This is the information for run yarn why canvas

yarn why v1.22.19
warning ../../package.json: No license field
[1/4] 🤔  Why do we have the module "canvas"...?
[2/4] 🚚  Initialising dependency graph...
warning Lockfile has incorrect entry for "[email protected]". Ignoring it.
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Reasons this module exists
   - "@types#react-pdf#@types#pdfjs-dist#pdfjs-dist" depends on it
   - Hoisted from "@types#react-pdf#@types#pdfjs-dist#pdfjs-dist#canvas"
✨  Done in 0.91s.

Your Environment

@jarmitage
Copy link

jarmitage commented Jan 3, 2023

Same issue of 404 at https://github.com/Automattic/node-canvas/releases/download/v2.11.0/canvas-v2.11.0-node-v108-darwin-unknown-arm64.tar.gz

node v18.12.1
macOS 12.6

@jarmitage
Copy link

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

@da-du
Copy link
Author

da-du commented Jan 3, 2023

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

But is it the right way to install so many packages?

@mn4367
Copy link

mn4367 commented Jan 3, 2023

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

But is it the right way to install so many packages?

It's related to #2036 and other similar issues. Currently it still seems to be impossible to build a self contained version of canvas, so you have to install dependencies by other means.

@Whobeu
Copy link

Whobeu commented Jan 20, 2023

I am running into this myself trying to run with Node.js 18 on Windows. There were no issues upgrading my Linux systems to Node.js 18 and "npm rebuild" worked fine. I am currently using Node.js 16.19.0 on Windows and it works fine. However, I just learned that the Node.js organization has moved the end-of-life for Node.js 16 forward seven months to September 2023, due to the OpenSSL end-of-life, so I realized I needed to look at Node.js 18 sooner than later for Windows.

UPDATE: I found the issue and it is rather odd. On Linux, everything works fine. "npm rebuild" updates the code to the latest Node platform. But on Windows it kept failing. Just for fun, I wiped the node_modules directory and did an "npm i". That worked. The correct node-canvas for Node 18 downloaded.

@Kaisarion
Copy link

can reproduce - macbook m1 ventura on a docker container
any fixes? have tried everything from a source build to an npm ci

@Orange-001
Copy link

Hey, guys! I also had the same issue. Maybe you can try creating an .npmrc file under the project root path, specifying the mirror address of the canvas, like this: canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas
It worked for me and I hope it helps you.

@LijiaHou
Copy link

Hey, guys! I also had the same issue. Maybe you can try creating an .npmrc file under the project root path, specifying the mirror address of the canvas, like this: canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas It worked for me and I hope it helps you.

Wow, bro, you're so cool! I installed it in the Windows environment for two days without success until I used your method!

@JianLin176
Copy link

大家好!我也有同样的问题。也许您可以尝试在项目根路径下创建一个 .npmrc 文件,指定画布的镜像地址,如下所示:canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas
它对我有用,希望对您有所帮助。

it work for me too.

@kddsultan
Copy link

kddsultan commented Sep 11, 2023

In case someone is upgrading to Nodejs v18, upgrade might be the solution

@Yurii397
Copy link

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

But is it the right way to install so many packages?

Looks it's expected way based on the canvas documentation - https://github.com/Automattic/node-canvas/wiki/Installation%3A-Mac-OS-X

@Whobeu
Copy link

Whobeu commented Dec 11, 2023

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

But is it the right way to install so many packages?

Looks it's expected way based on the canvas documentation - https://github.com/Automattic/node-canvas/wiki/Installation%3A-Mac-OS-X

I have several Raspberry's that I use with node-canvas. Finally created myself a tiny bash script to handle it:

#!/bin/bash

read -p "Do you want to install the libraries for node-canvas? " -n 1 -r
echo    # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
  echo Installing packages required for installation of node-canvas
  sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
fi

There was a reason the -dev packages were required but I have forgotten.

@335296558
Copy link

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

Mine is m1, this method helped me solve the problem

@Imeth97
Copy link

Imeth97 commented Jan 28, 2024

I have the same issue, running
yarn install --ignore-optional
has fixed it for me for now. Canvas is only an optional dependency for react-pdf it seems

@suyash-purwar
Copy link

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

This doesn't fix anything for me. Using node version v14.21.3 on macOS 14.

@bora001
Copy link

bora001 commented Jun 5, 2024

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

Brew install did't work for me, but after adding "node-gyp," it worked fine. (+ removed node_modules)
If it still doesn't work for you, maybe you can try running "npm install" or "yarn" after downloading canvas individually.

  • Solved : Added "node-gyp"
   "node-gyp": "^10.1.0",
  • Environment
  "canvas": "^2.11.2"
  "node": ">= v18.18.1",
  Mac : M1 macOS Ventura 13.4

@pedroagcf
Copy link

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

@nguyenvhung9420
Copy link

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

Brew install did't work for me, but after adding "node-gyp," it worked fine. (+ removed node_modules) If it still doesn't work for you, maybe you can try running "npm install" or "yarn" after downloading canvas individually.

  • Solved : Added "node-gyp"
   "node-gyp": "^10.1.0",
  • Environment
  "canvas": "^2.11.2"
  "node": ">= v18.18.1",
  Mac : M1 macOS Ventura 13.4

Tks @bora001 your solution worked for me on Windows.

@natikos
Copy link

natikos commented Oct 24, 2024

I'm facing the same issue while installing [email protected]

node: v20.14.0
macOS: 15.0.1 (M2)

The error was related to being unable to run the make command. I fixed it by completely reinstalling Xcode with the following steps:

sudo rm -rf /Applications/Xcode.app
sudo rm -rf /Library/Developer/CommandLineTools
sudo rm -rf ~/Library/Developer/CoreSimulator
sudo rm -rf ~/Library/Developer/Xcode
sudo rm -rf /Library/Developer/Xcode
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Containers/com.apple.dt.Xcode

xcode-select --install

@tiennguyen1293
Copy link

I followed this step and its worked for me
wojtekmaj/react-pdf#1589 (comment)

@jose-aiq
Copy link

Fixed for me: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

This work for me, running on mac m1 with macos 15.0.1

@Aarbel
Copy link

Aarbel commented Oct 30, 2024

Solution that definitely solved the problem for us, just run the npm install or yarn inside python environment:

python3 -m venv venv
source venv/bin/activate
pip install setuptools wheel

yarn

deactivate 

@chearon
Copy link
Collaborator

chearon commented Dec 8, 2024

There are several different types of issues in the comments, but since #2354 was merged, I don't think the issue in the OP would happen so I'm going to close it. Following the install instructions (#2186 (comment)) also would have worked.

npm install canvas@next to get 3.0.0-rc3. I'm going to wait a few days before releasing 3.0.

@chearon chearon closed this as completed Dec 8, 2024
@SHADDOCKTREE
Copy link

There are several different types of issues in the comments, but since #2354 was merged, I don't think the issue in the OP would happen so I'm going to close it. Following the install instructions (#2186 (comment)) also would have worked.

npm install canvas@next to get 3.0.0-rc3. I'm going to wait a few days before releasing 3.0.

that works for me !!
mac M2
nvm v0.40.1
node v23.4.0

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

No branches or pull requests