Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.2k stars 1.17k forks source link

unable to install node-canvas on mac os 15.0(sequoia) #2433

Open satyajitnayk opened 2 months ago

satyajitnayk commented 2 months ago

Issue or Feature

Steps to Reproduce

getting node-gyp error when installing canvas on latest mac version. node version v20.10.0

Your Environment

npm ERR! A complete log of this run can be found in: /Users/satyajitnayak/.npm/_logs/2024-09-26T16_11_52_180Z-debug-0.log



* Environment : node 20.10.0 on macOS 15.0(sequoia)
cmahnke commented 2 months ago

Same problem here, given the last release date and previous issues - maybe it's time to deprecate the module?

satyajitnayk commented 2 months ago

@cmahnke uninstalling & installing back xcode command line tools worked for me for now.

 sudo rm -rf /Library/Developer/CommandLineTools
 xcode-select --install                         

do not update xcode command line tools further

image
alvis commented 1 month ago

Thanks @satyajitnayk for the hint. It works for me too

pedrokohler commented 1 month ago

@cmahnke uninstalling & installing back xcode command line tools worked for me for now.

sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install
do not update xcode command line tools further

@satyajitnayk I've tried this with macOS 15.0.1 (sequoia) and nodejs v22.8.0 but no luck. I've still got the same issues.

error /Users/work/projects/cornerstone/node_modules/canvas: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build --update-binary
Arguments: 
Directory: /Users/work/projects/cornerstone/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@22.8.0 | darwin | arm64
(node:63219) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v127-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-v127-darwin-unknown-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@22.8.0 (node-v127 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-v127-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@22.8.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@22.8.0 | darwin | arm64
(node:63247) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
gyp info find Python using Python version 3.12.6 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/work/projects/cornerstone/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/work/projects/cornerstone/node_modules/canvas/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/work/projects/cornerstone/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/work/Library/Caches/node-gyp/22.8.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/work/Library/Caches/node-gyp/22.8.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/work/projects/cornerstone/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/work/Library/Caches/node-gyp/22.8.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/work/projects/cornerstone/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 ]
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@22.8.0 | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  SOLINK_MODULE(target) Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/backend/Backend.o
In file included from ../src/backend/Backend.cc:1:
In file included from ../src/backend/Backend.h:6:
../../nan/nan.h:2548:8: error: no matching member function for call to 'SetAccessor'
 2548 |   tpl->SetAccessor(
      |   ~~~~~^~~~~~~~~~~
/Users/work/Library/Caches/node-gyp/22.8.0/include/node/v8-template.h:1055:8: note: candidate function not viable: no known conversion from 'v8::AccessControl' to 'PropertyAttribute' for 5th argument
 1055 |   void SetAccessor(
      |        ^
 1056 |       Local<Name> name, AccessorNameGetterCallback getter,
 1057 |       AccessorNameSetterCallback setter = nullptr,
 1058 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
      |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/work/Library/Caches/node-gyp/22.8.0/include/node/v8-template.h:1049:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'AccessorGetterCallback' (aka 'void (*)(Local<String>, const PropertyCallbackInfo<Value> &)') for 2nd argument
 1049 |   void SetAccessor(
      |        ^
 1050 |       Local<String> name, AccessorGetterCallback getter,
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/backend/Backend.cc:1:
In file included from ../src/backend/Backend.h:6:
../../nan/nan.h:2594:8: error: no matching member function for call to 'SetAccessor'
 2594 |   tpl->SetAccessor(
      |   ~~~~~^~~~~~~~~~~
/Users/work/Library/Caches/node-gyp/22.8.0/include/node/v8-template.h:1055:8: note: candidate function not viable: no known conversion from 'v8::AccessControl' to 'PropertyAttribute' for 5th argument
 1055 |   void SetAccessor(
      |        ^
 1056 |       Local<Name> name, AccessorNameGetterCallback getter,
 1057 |       AccessorNameSetterCallback setter = nullptr,
 1058 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
      |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/work/Library/Caches/node-gyp/22.8.0/include/node/v8-template.h:1049:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'AccessorGetterCallback' (aka 'void (*)(Local<String>, const PropertyCallbackInfo<Value> &)') for 2nd argument
 1049 |   void SetAccessor(
      |        ^
 1050 |       Local<String> name, AccessorGetterCallback getter,
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/backend/Backend.cc:1:
../src/backend/Backend.h:60:14: warning: private field 'backend' is not used [-Wunused-private-field]
   60 |     Backend* backend;
      |              ^
1 warning and 2 errors generated.
make: *** [Release/obj.target/canvas/src/backend/Backend.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/work/projects/cornerstone/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Darwin 24.0.0
gyp ERR! command "/opt/homebrew/Cellar/node/22.8.0/bin/node" "/Users/work/projects/cornerstone/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--update-binary" "--module=/Users/work/projects/cornerstone/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/Users/work/projects/cornerstone/node_modules/canvas/build/Release" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v127"
gyp ERR! cwd /Users/work/projects/cornerstone/node_modules/canvas
gyp ERR! node -v v22.8.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 '/opt/homebrew/Cellar/node/22.8.0/bin/node /Users/work/projects/cornerstone/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/Users/work/projects/cornerstone/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/work/projects/cornerstone/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v127' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/work/projects/cornerstone/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:520: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 24.0.0
node-pre-gyp ERR! command "/opt/homebrew/Cellar/node/22.8.0/bin/node" "/Users/work/projects/cornerstone/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
node-pre-gyp ERR! cwd /Users/work/projects/cornerstone/node_modules/canvas
node-pre-gyp ERR! node -v v22.8.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.11
node-pre-gyp ERR! not ok 
alvis commented 1 month ago

@pedrokohler Have you tried installing it using node 20 LTS instead of 22?

pedrokohler commented 1 month ago

@alvis it did not work either. I think I'll have to rollback to macOS version 14

clhenrick commented 1 month ago

I ran into a similar issue and the following fixed this for me on Mac OS 14.7:

  1. Installed the Command Line Tools from the XCode app (well really by downloading them from developer.apple.com and then installing them using the Command_Line_Tools_for_Xcode_16.dmg file)

  2. Updated the path to the Command Line Tools in the terminal by doing: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/

I was then able to successfully install node-canvas on my system.

SHiftLin commented 1 month ago

brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman This works for me

schanzer commented 1 month ago

I'm getting the exact same errors -- I've been running node canvas for years until prior versions of OSX (sometimes with a little fiddling around node versions or brew packages), but this is the first time I've been totally blocked from using it.

silberjan commented 1 month ago

same issue for me. Mac OS 15.0.1

mfauveau commented 4 weeks ago

Did the uninstall/reinstall of xcode, but ultimately downgrading to node 20 solved the issue (nvm use 20).

wang1212 commented 3 weeks ago

For me, downgrading from node v20.15.1 to node v18.20.4 worked.