Automattic / Automattic/node-canvas
Installation fails: "../src/backend/Backend.h:3:10: fatal error: 'cairo.h' file not found"
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
## Issue of Installation
- [x] If this is an issue with installation, I have read the [troubleshooting guide](https://github.com/Automattic/node-canvas/issues/1511).
## Steps to Reproduce
1. I've already installed dependencies like this, and It's successful:
``` shell
$ brew install pkg-config cairo pango libpng jpeg giflib librsvg
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
Updated 2 formulae.
==> New Casks
mathcha-notebook
==> Updated Casks
Updated 28 casks.
Warning: pkg-config 0.29.2_3 is already installed and up-to-date.
To reinstall 0.29.2_3, run:
brew reinstall pkg-config
Warning: cairo 1.16.0_5 is already installed and up-to-date.
To reinstall 1.16.0_5, run:
brew reinstall cairo
Warning: pango 1.48.9 is already installed and up-to-date.
To reinstall 1.48.9, run:
brew reinstall pango
Warning: libpng 1.6.37 is already installed and up-to-date.
To reinstall 1.6.37, run:
brew reinstall libpng
Warning: jpeg 9d is already installed and up-to-date.
To reinstall 9d, run:
brew reinstall jpeg
Warning: giflib 5.2.1 is already installed and up-to-date.
To reinstall 5.2.1, run:
brew reinstall giflib
Warning: librsvg 2.50.7 is already installed and up-to-date.
To reinstall 2.50.7, run:
brew reinstall librsvg
```
2. I've already re-installed the command line tools like this:
``` shell
$ rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
```
3. Then I use 'npm install canvas' to install node-canvas, it goes error:
``` shell
$ npm install -g canvas
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! SOLINK_MODULE(target) Release/canvas-postbuild.node
npm ERR! CXX(target) Release/obj.target/canvas/src/backend/Backend.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@12.18.3 | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "/usr/local/opt/python@3.9/bin/python3.9"
npm ERR! gyp info spawn /usr/local/opt/python@3.9/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/canvas/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/tazen/Library/Caches/node-gyp/12.18.3/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/tazen/Library/Caches/node-gyp/12.18.3',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/tazen/Library/Caches/node-gyp/12.18.3/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/canvas',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/backend/Backend.cc:1:
npm ERR! ../src/backend/Backend.h:3:10: fatal error: 'cairo.h' file not found
npm ERR! #include
npm ERR! ^~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/canvas/src/backend/Backend.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/canvas
npm ERR! gyp ERR! node -v v12.18.3
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
```
## Your Environment
* Version of node-canvas: Not installed yet.
* Environment: Mac OS X11.5.2, Node v12.18.3
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.