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

npm intall not working on node v22 #2377

Closed
1 task done
hong6316 opened this issue Apr 25, 2024 · 12 comments
Closed
1 task done

npm intall not working on node v22 #2377

hong6316 opened this issue Apr 25, 2024 · 12 comments

Comments

@hong6316
Copy link

hong6316 commented Apr 25, 2024

Issue or Feature

npm intall not working on node v22.
I checked #1511 but the error log is not the same
I already proceed the below step but It's not working on node 22(other node versions work fine)
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

https://app.travis-ci.com/github/enactjs/sandstone/jobs/620963689

npm ERR! code 1
npm ERR! path /home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build --update-binary
npm ERR! make: Entering directory '/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build'
npm ERR!   SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
npm ERR!   COPY Release/canvas-postbuild.node
npm ERR!   CXX(target) Release/obj.target/canvas/src/backend/Backend.o
npm ERR! make: Leaving directory '/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build'
npm ERR! Failed to execute '/home/travis/.nvm/versions/node/v22.0.0/bin/node /home/travis/.nvm/versions/node/v22.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v127' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.11
npm ERR! node-pre-gyp info using node@22.0.0 | linux | x64
npm ERR! (node:10122) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v127-linux-glibc-x64.tar.gz
npm ERR! 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-linux-glibc-x64.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@22.0.0 (node-v127 ABI, glibc) (falling back to source compile with node-gyp) 
npm ERR! 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-linux-glibc-x64.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.1.0
npm ERR! gyp info using node@22.0.0 | linux | x64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.1.0
npm ERR! gyp info using node@22.0.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.7.17 found at "/opt/pyenv/versions/3.7.17/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v22.0.0/node-v22.0.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v22.0.0/node-v22.0.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v22.0.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v22.0.0/SHASUMS256.txt
npm ERR! gyp info spawn /opt/pyenv/versions/3.7.17/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/travis/.nvm/versions/node/v22.0.0/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 '/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/travis/.nvm/versions/node/v22.0.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/travis/.cache/node-gyp/22.0.0/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=/home/travis/.cache/node-gyp/22.0.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/travis/.nvm/versions/node/v22.0.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/travis/.cache/node-gyp/22.0.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/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 ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.1.0
npm ERR! gyp info using node@22.0.0 | linux | x64
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.h:6,
npm ERR!                  from ../src/backend/Backend.cc:1:
npm ERR! ../../nan/nan.h: In function ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’:
npm ERR! ../../nan/nan.h:2558:3: error: no matching function for call to ‘v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>&, void (*&)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&), void (*&)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&), v8::Local<v8::Object>&, v8::AccessControl&, v8::PropertyAttribute&)’
npm ERR!  2558 |   );
npm ERR!       |   ^
npm ERR! In file included from /home/travis/.cache/node-gyp/22.0.0/include/node/v8-function.h:15,
npm ERR!                  from /home/travis/.cache/node-gyp/22.0.0/include/node/v8.h:33,
npm ERR!                  from /home/travis/.cache/node-gyp/22.0.0/include/node/node.h:73,
npm ERR!                  from ../../nan/nan.h:62,
npm ERR!                  from ../src/backend/Backend.h:6,
npm ERR!                  from ../src/backend/Backend.cc:1:
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1049:8: note: candidate: ‘void v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>, v8::AccessorGetterCallback, v8::AccessorSetterCallback, v8::Local<v8::Value>, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)’
npm ERR!  1049 |   void SetAccessor(
npm ERR!       |        ^~~~~~~~~~~
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1052:61: note:   no known conversion for argument 5 from ‘v8::AccessControl’ to ‘v8::PropertyAttribute’
npm ERR!  1052 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
npm ERR!       |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1055:8: note: candidate: ‘void v8::ObjectTemplate::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local<v8::Value>, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)’
npm ERR!  1055 |   void SetAccessor(
npm ERR!       |        ^~~~~~~~~~~
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1058:61: note:   no known conversion for argument 5 from ‘v8::AccessControl’ to ‘v8::PropertyAttribute’
npm ERR!  1058 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
npm ERR!       |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
npm ERR! In file included from ../src/backend/Backend.h:6,
npm ERR!                  from ../src/backend/Backend.cc:1:
npm ERR! ../../nan/nan.h: In function ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)’:
npm ERR! ../../nan/nan.h:2601:3: error: no matching function for call to ‘v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>&, void (*&)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&), void (*&)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&), v8::Local<v8::Object>&, v8::AccessControl&, v8::PropertyAttribute&)’
npm ERR!  2601 |   );
npm ERR!       |   ^
npm ERR! In file included from /home/travis/.cache/node-gyp/22.0.0/include/node/v8-function.h:15,
npm ERR!                  from /home/travis/.cache/node-gyp/22.0.0/include/node/v8.h:33,
npm ERR!                  from /home/travis/.cache/node-gyp/22.0.0/include/node/node.h:73,
npm ERR!                  from ../../nan/nan.h:62,
npm ERR!                  from ../src/backend/Backend.h:6,
npm ERR!                  from ../src/backend/Backend.cc:1:
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1049:8: note: candidate: ‘void v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>, v8::AccessorGetterCallback, v8::AccessorSetterCallback, v8::Local<v8::Value>, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)’
npm ERR!  1049 |   void SetAccessor(
npm ERR!       |        ^~~~~~~~~~~
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1052:61: note:   no known conversion for argument 5 from ‘v8::AccessControl’ to ‘v8::PropertyAttribute’
npm ERR!  1052 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
npm ERR!       |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1055:8: note: candidate: ‘void v8::ObjectTemplate::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local<v8::Value>, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)’
npm ERR!  1055 |   void SetAccessor(
npm ERR!       |        ^~~~~~~~~~~
npm ERR! /home/travis/.cache/node-gyp/22.0.0/include/node/v8-template.h:1058:61: note:   no known conversion for argument 5 from ‘v8::AccessControl’ to ‘v8::PropertyAttribute’
npm ERR!  1058 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
npm ERR!       |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
npm ERR! make: *** [canvas.target.mk:159: 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.<anonymous> (/home/travis/.nvm/versions/node/v22.0.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 5.15.0-1049-gcp
npm ERR! gyp ERR! command "/home/travis/.nvm/versions/node/v22.0.0/bin/node" "/home/travis/.nvm/versions/node/v22.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--update-binary" "--module=/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build/Release" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v127"
npm ERR! gyp ERR! cwd /home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas
npm ERR! gyp ERR! node -v v22.0.0
npm ERR! gyp ERR! node-gyp -v v10.1.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/home/travis/.nvm/versions/node/v22.0.0/bin/node /home/travis/.nvm/versions/node/v22.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v127' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! node-pre-gyp ERR! System Linux 5.15.0-1049-gcp
npm ERR! node-pre-gyp ERR! command "/home/travis/.nvm/versions/node/v22.0.0/bin/node" "/home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
npm ERR! node-pre-gyp ERR! cwd /home/travis/build/enactjs/enact/packages/i18n/node_modules/@enact/ui-test-utils/node_modules/canvas
npm ERR! node-pre-gyp ERR! node -v v22.0.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm ERR! node-pre-gyp ERR! not ok
npm ERR! A complete log of this run can be found in: /home/travis/.npm/_logs/2024-04-25T05_35_01_147Z-debug-0.log

Steps to Reproduce

https://app.travis-ci.com/github/enactjs/sandstone/jobs/620963689

$ sudo apt-get update
$ sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

...

$ git clone --branch=develop --depth 1 https://github.com/enactjs/enact ../enact
$ pushd ../enact
$ npm install
$ npm run lerna exec -- --ignore enact-sampler --concurrency 1 -- npm --no-package-lock install
// etc.

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas): v2.11.2
  • Environment (e.g. node 20.9.0 on macOS 14.1.1): node 22.0.0 on Ubuntu 20.04.6 LTS
nicolo-ribaudo added a commit to nicolo-ribaudo/pdf.js that referenced this issue Apr 26, 2024
Node.js 22 was just released, and it seems like it's not compatible
with the `canvas` package. This commit pins the version on GitHub
actions to Node.js 21 as a temporary workaround.

This commit should be reverted once
Automattic/node-canvas#2377
is fixed.
@nicolo-ribaudo
Copy link

Node.js 22 includes v8/v8@e48c472, which removed the v8::AccessControl settings parameter from v8::ObjectTemplate::SetAccessor.

v8::ObjectTemplate::SetAccessor(
  v8::Local<v8::String>&,
  void (*&)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&),
  void (*&)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&),
  v8::Local<v8::Object>&,
  v8::AccessControl&, // Removed!
  v8::PropertyAttribute&
)

#2235 probably fixed this problem by not using nan anymore, but it hasn't been released to npm yet.

@imrefazekas
Copy link

@hong6316 use

        "canvas": "Automattic/node-canvas#master",

in your package.json for the time being ... Works with node 22

domoritz added a commit to vega/vega-lite that referenced this issue Apr 30, 2024
domoritz added a commit to vega/vega that referenced this issue Apr 30, 2024
domoritz added a commit to vega/vega that referenced this issue Apr 30, 2024
domoritz added a commit to vega/vega-lite that referenced this issue Apr 30, 2024
@hong6316
Copy link
Author

hong6316 commented May 3, 2024

@hong6316 use

        "canvas": "Automattic/node-canvas#master",

in your package.json for the time being ... Works with node 22

That's not possible, I didn't add the canvas module directly to package.json.
The 3rd party module uses canvas.

@imrefazekas
Copy link

imrefazekas commented May 5, 2024

@hong6316
You can still use this npm feature: "overrides"?

https://github.com/npm/cli/releases/tag/v8.3.0

@mbrevda
Copy link

mbrevda commented May 23, 2024

Adding overrides doesn't seem to be working with bun:

  "overrides": {
    "canvas": "Automattic/node-canvas#master"
  }
bun i
[0.06ms] ".env"
bun install v1.1.9 (bb13798d)
[13.25ms] migrated lockfile from package-lock.json
error: canvas@^2.11.2 failed to resolve
error: canvas@^2.11.2 failed to resolve

@liesauer
Copy link

v20.13.1 is not working either.

@liesauer
Copy link

this package is killing me, i have no idea what to do now.

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.11.0
node-pre-gyp info using node@18.20.3 | linux | x64
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp info check checked for "/mnt/f/Projects/xxx/node_modules/canvas/build/Release/canvas.node" (not found)
node-pre-gyp http GET https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.5.0/canvas-v2.5.0-node-v108-linux-glibc-x64.tar.gz
node-pre-gyp http 404 https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.5.0/canvas-v2.5.0-node-v108-linux-glibc-x64.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.5.0/canvas-v2.5.0-node-v108-linux-glibc-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for canvas@2.5.0 and node@18.20.3 (node-v108 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp http 404 status code downloading tarball https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.5.0/canvas-v2.5.0-node-v108-linux-glibc-x64.tar.gz 
gyp info it worked if it ends with ok
gyp info using node-gyp@10.1.0
gyp info using node@18.20.3 | linux | x64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@10.1.0
gyp info using node@18.20.3 | linux | x64
gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"

gyp http GET https://nodejs.org/download/release/v18.20.3/node-v18.20.3-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v18.20.3/node-v18.20.3-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v18.20.3/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v18.20.3/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/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 '/mnt/f/Projects/xxx/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/user1/.cache/node-gyp/18.20.3/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/user1/.cache/node-gyp/18.20.3',
gyp info spawn args '-Dnode_gyp_dir=/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/user1/.cache/node-gyp/18.20.3/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/mnt/f/Projects/xxx/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@10.1.0
gyp info using node@18.20.3 | linux | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/mnt/f/Projects/xxx/node_modules/canvas/build'
  SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
  COPY Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/backend/Backend.o
  CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
../src/backend/ImageBackend.cc: In static member function ‘static void ImageBackend::Initialize(v8::Local<v8::Object>)’:
../src/backend/ImageBackend.cc:70:56: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
   70 |               ctor->GetFunction(v8ctx).ToLocalChecked());
      |                                                        ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/backend/ImageBackend.h:3,
                 from ../src/backend/ImageBackend.cc:1:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:246:37: note: declared here
  246 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
  CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
../src/backend/PdfBackend.cc: In static member function ‘static void PdfBackend::Initialize(v8::Local<v8::Object>)’:
../src/backend/PdfBackend.cc:49:56: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
   49 |               ctor->GetFunction(v8ctx).ToLocalChecked());
      |                                                        ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/backend/PdfBackend.h:3,
                 from ../src/backend/PdfBackend.cc:1:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:246:37: note: declared here
  246 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
  CXX(target) Release/obj.target/canvas/src/backend/SvgBackend.o
../src/backend/SvgBackend.cc: In static member function ‘static void SvgBackend::Initialize(v8::Local<v8::Object>)’:
../src/backend/SvgBackend.cc:51:56: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
   51 |               ctor->GetFunction(v8ctx).ToLocalChecked());
      |                                                        ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/backend/SvgBackend.h:3,
                 from ../src/backend/SvgBackend.cc:1:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:246:37: note: declared here
  246 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
  CXX(target) Release/obj.target/canvas/src/bmp/BMPParser.o
  CXX(target) Release/obj.target/canvas/src/Backends.o
../src/Backends.cc: In static member function ‘static void Backends::Initialize(v8::Local<v8::Object>)’:
../src/Backends.cc:18:72: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
   18 |   target->Set(v8ctx, Nan::New<String>("Backends").ToLocalChecked(), obj);
      |                                                                        ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/Backends.h:3,
                 from ../src/Backends.cc:1:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:246:37: note: declared here
  246 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
  CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/Canvas.cc:21:
../src/Util.h: In function ‘void SetProtoAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::FunctionTemplate>)’:
../src/Util.h:26:2: warning: ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’ is deprecated [-Wdeprecated-declarations]
   26 |  );
      |  ^
In file included from ../src/backend/Backend.h:6,
                 from ../src/Canvas.h:5,
                 from ../src/Canvas.cc:3:
../../nan/nan.h:2514:28: note: declared here
 2514 | NAN_DEPRECATED inline void SetAccessor(
      |                            ^~~~~~~~~~~
In file included from ../src/Canvas.cc:21:
../src/Util.h:26:2: warning: ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’ is deprecated [-Wdeprecated-declarations]
   26 |  );
      |  ^
In file included from ../src/backend/Backend.h:6,
                 from ../src/Canvas.h:5,
                 from ../src/Canvas.cc:3:
../../nan/nan.h:2514:28: note: declared here
 2514 | NAN_DEPRECATED inline void SetAccessor(
      |                            ^~~~~~~~~~~
../src/Canvas.cc: In function ‘void setPdfMetaStr(cairo_surface_t*, v8::Local<v8::Object>, cairo_pdf_metadata_t, const char*)’:
../src/Canvas.cc:327:25: error: no matching function for call to ‘v8::Object::Get(v8::Local<v8::String>&)’
  327 |   if (opts->Get(propName)->IsString()) {
      |                         ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/Canvas.h:5,
                 from ../src/Canvas.cc:3:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)’
  292 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note:   candidate expects 2 arguments, 1 provided
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, uint32_t)’
  295 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note:   candidate expects 2 arguments, 1 provided
../src/Canvas.cc:328:34: error: no matching function for call to ‘v8::Object::Get(v8::Local<v8::String>&)’
  328 |     auto val = opts->Get(propName);
      |                                  ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/Canvas.h:5,
                 from ../src/Canvas.cc:3:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)’
  292 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note:   candidate expects 2 arguments, 1 provided
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, uint32_t)’
  295 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note:   candidate expects 2 arguments, 1 provided
../src/Canvas.cc: In function ‘void setPdfMetaDate(cairo_surface_t*, v8::Local<v8::Object>, cairo_pdf_metadata_t, const char*)’:
../src/Canvas.cc:337:25: error: no matching function for call to ‘v8::Object::Get(v8::Local<v8::String>&)’
  337 |   if (opts->Get(propName)->IsDate()) {
      |                         ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/Canvas.h:5,
                 from ../src/Canvas.cc:3:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)’
  292 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note:   candidate expects 2 arguments, 1 provided
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, uint32_t)’
  295 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note:   candidate expects 2 arguments, 1 provided
../src/Canvas.cc:338:34: error: no matching function for call to ‘v8::Object::Get(v8::Local<v8::String>&)’
  338 |     auto val = opts->Get(propName).As<Date>();
      |                                  ^
In file included from /home/user1/.cache/node-gyp/18.20.3/include/node/v8-array-buffer.h:13,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/v8.h:24,
                 from /home/user1/.cache/node-gyp/18.20.3/include/node/node.h:73,
                 from ../../nan/nan.h:62,
                 from ../src/backend/Backend.h:6,
                 from ../src/Canvas.h:5,
                 from ../src/Canvas.cc:3:
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)’
  292 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:292:43: note:   candidate expects 2 arguments, 1 provided
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, uint32_t)’
  295 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/user1/.cache/node-gyp/18.20.3/include/node/v8-object.h:295:43: note:   candidate expects 2 arguments, 1 provided
../src/Canvas.cc:338:43: error: expected primary-expression before ‘>’ token
  338 |     auto val = opts->Get(propName).As<Date>();
      |                                           ^
../src/Canvas.cc:338:45: error: expected primary-expression before ‘)’ token
  338 |     auto val = opts->Get(propName).As<Date>();
      |                                             ^
../src/Canvas.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Canvas::ToBuffer(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/Canvas.cc:475:79: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  475 |     uv_queue_work(uv_default_loop(), req, ToPngBufferAsync, (uv_after_work_cb)ToBufferAsyncAfter);
      |                                                                               ^~~~~~~~~~~~~~~~~~
../src/Canvas.cc:516:80: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  516 |     uv_queue_work(uv_default_loop(), req, ToJpegBufferAsync, (uv_after_work_cb)ToBufferAsyncAfter);
      |                                                                                ^~~~~~~~~~~~~~~~~~
make: *** [canvas.target.mk:160: Release/obj.target/canvas/src/Canvas.o] Error 1
make: Leaving directory '/mnt/f/Projects/xxx/node_modules/canvas/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.<anonymous> (/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
gyp ERR! System Linux 5.15.133.1-microsoft-standard-WSL2
gyp ERR! command "/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/bin/node" "/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/mnt/f/Projects/xxx/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/mnt/f/Projects/xxx/node_modules/canvas/build/Release" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
gyp ERR! cwd /mnt/f/Projects/xxx/node_modules/canvas
gyp ERR! node -v v18.20.3
gyp ERR! node-gyp -v v10.1.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/bin/node /home/user1/.local/share/fnm/node-versions/v18.20.3/installation/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/mnt/f/Projects/xxx/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/mnt/f/Projects/xxx/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/mnt/f/Projects/xxx/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1098:16)
node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:303:5)
node-pre-gyp ERR! System Linux 5.15.133.1-microsoft-standard-WSL2
node-pre-gyp ERR! command "/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/bin/node" "/mnt/f/Projects/xxx/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /mnt/f/Projects/xxx/node_modules/canvas
node-pre-gyp ERR! node -v v18.20.3
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/home/user1/.local/share/fnm/node-versions/v18.20.3/installation/bin/node /home/user1/.local/share/fnm/node-versions/v18.20.3/installation/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/mnt/f/Projects/xxx/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/mnt/f/Projects/xxx/node_modules/canvas/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@letharion
Copy link

this package is killing me, i have no idea what to do now.

Are you sure you're using Node 20? The output you posted suggests you're on Node 18.
However the error, as I understand it, wasn't introduced until after 20, so I don't know how you manage to reproduce it with an even older version.

I solved the issue by downgrading from 22 to 20. Double check your versions, and perhaps restart your terminal so you don't have an old version lingering around referenced in an environment variable.

@liesauer
Copy link

liesauer commented Jun 2, 2024

@letharion i have tried node 18 and node 20, both of them are failed. after upgrade the canvas package, and it just works(i can confirm that the previous version of canvas should support node 18, because i copy the package.json depencies from my another pc).

@zbjornson
Copy link
Collaborator

Anyone using Windows x64 or Linux x64/glibc, please try npm install canvas@next to install v3.0.0-rc2. If you run into any problems, please open a new GitHub issue.

For any other platforms and architectures, v3.0.0 can be built from source following the compilation section of the readme. MacOS prebuilds should be coming soon.

@basex
Copy link

basex commented Oct 17, 2024

With yarn I was able to fix by adding to package.json

  "resolutions": {
    "canvas": "Automattic/node-canvas#master"
  },

@melMass
Copy link

melMass commented Oct 25, 2024

Nice, I went with:

 "resolutions": {
    "canvas": "github:Automattic/node-canvas#a2e10e6"
  }

jcoyne added a commit to ProjectMirador/mirador that referenced this issue Oct 29, 2024
Needed to upgrade canvas to a git rev due to Automattic/node-canvas#2377
jcoyne added a commit to ProjectMirador/mirador that referenced this issue Oct 29, 2024
Needed to upgrade canvas to a git rev due to Automattic/node-canvas#2377
cbeer pushed a commit to ProjectMirador/mirador that referenced this issue Oct 29, 2024
Needed to upgrade canvas to a git rev due to Automattic/node-canvas#2377
jcoyne added a commit to ProjectMirador/mirador that referenced this issue Oct 29, 2024
Needed to upgrade canvas to a git rev due to Automattic/node-canvas#2377
jcoyne added a commit to ProjectMirador/mirador that referenced this issue Oct 29, 2024
Needed to upgrade canvas to a git rev due to Automattic/node-canvas#2377
karlhorky added a commit to upleveled/security-vulnerability-examples-next-js-postgres that referenced this issue Nov 6, 2024
karlhorky added a commit to upleveled/security-vulnerability-examples-next-js-postgres that referenced this issue Nov 7, 2024
* Remove @types/cookie stub

* Remove @types/cookie from lockfile

* Upgrade to node-addon-api@7.1.0

* Upgrade to canvas@3.0.0-rc2

- https://github.com/Automattic/node-canvas/releases/tag/v3.0.0-rc2
- Automattic/node-canvas#2377 (comment)

* Upgrade to node-gyp@10.2.0

* Install pango and cairo

* Change to pull_request trigger

* Switch back to only `push` trigger

Revert this for now: 3d62d34#diff-def01120c202f13a2f33e11a966318cd2b5f80b66a28ea61d68001c56fd53214R4
cbeer pushed a commit to ProjectMirador/mirador that referenced this issue Nov 27, 2024
Needed to upgrade canvas to a git rev due to Automattic/node-canvas#2377
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

9 participants