nodejs/node-gyp

Getting error while installing canvas using npm

rahuljustbaat opened this issue · 8 comments

Please look thru your error log for the string gyp info using node-gyp@ and if the version number is less than the current release of node-gyp then please upgrade using the instructions at https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md and try your command again.

Requests for help with node-sass are very common. Please be aware that this package is deprecated, you should seek alternatives and avoid opening new issues about it here.

Verbose output (from npm or node-gyp):
Progress: resolved 1, reused 0, downloaded 0, added 0
Progress: resolved 21, reused 21, downloaded 0, added 0
Progress: resolved 44, reused 42, downloaded 0, added 0
Progress: resolved 255, reused 254, downloaded 0, added 0
Progress: resolved 403, reused 403, downloaded 0, added 0
Progress: resolved 411, reused 411, downloaded 0, added 0
 WARN  19 deprecated subdependencies found: @npmcli/move-file@2.0.1, abab@2.0.6, are-we-there-yet@2.0.0, are-we-there-yet@3.0.1, domexception@1.0.1, gauge@3.0.2, gauge@4.0.4, glob@7.2.3, glob@8.1.0, har-validator@5.1.5, inflight@1.0.6, npmlog@5.0.1, npmlog@6.0.2, querystring@0.2.0, request-promise-native@1.0.9, request@2.88.2, rimraf@3.0.2, uuid@3.4.0, w3c-hr-time@1.0.2
Packages: +414
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 414, reused 414, downloaded 0, added 0, done
.../.pnpm/gl@5.0.3/node_modules/gl install$ prebuild-install || node-gyp rebuild
.../node_modules/canvas install$ node-pre-gyp install --fallback-to-build --update-binary
.../node_modules/canvas install: node-pre-gyp info it worked if it ends with ok
.../node_modules/canvas install: node-pre-gyp info using node-pre-gyp@1.0.11
.../node_modules/canvas install: node-pre-gyp info using node@22.4.1 | darwin | x64
.../node_modules/canvas install: (node:69584) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
.../node_modules/canvas install: (Use `node --trace-deprecation ...` to show where the warning was created)
.../node_modules/canvas install: node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v127-darwin-unknown-x64.tar.gz
.../.pnpm/gl@5.0.3/node_modules/gl install: prebuild-install warn install No prebuilt binaries found (target=22.4.1 runtime=node arch=x64 libc= platform=darwin)
.../node_modules/canvas install: 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-x64.tar.gz 
.../node_modules/canvas install: node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@22.4.1 (node-v127 ABI, unknown) (falling back to source compile with node-gyp) 
.../node_modules/canvas install: 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-x64.tar.gz 
.../node_modules/canvas install: gyp info it worked if it ends with ok
.../node_modules/canvas install: gyp info using node-gyp@10.2.0
.../node_modules/canvas install: gyp info using node@22.4.1 | darwin | x64
.../node_modules/canvas install: gyp info ok 
.../node_modules/canvas install: gyp info it worked if it ends with ok
.../node_modules/canvas install: gyp info using node-gyp@10.2.0
.../node_modules/canvas install: gyp info using node@22.4.1 | darwin | x64
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info it worked if it ends with ok
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info using node-gyp@9.4.1
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info using node@22.4.1 | darwin | x64
.../.pnpm/gl@5.0.3/node_modules/gl install: (node:69602) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
.../.pnpm/gl@5.0.3/node_modules/gl install: (Use `node --trace-deprecation ...` to show where the warning was created)
.../node_modules/canvas install: gyp info find Python using Python version 3.9.6 found at "/Users/rahulkathuria/Documents/justbaat/optimus/tts/tts_env/bin/python3"
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info find Python using Python version 3.9.6 found at "/Users/rahulkathuria/Documents/justbaat/optimus/tts/tts_env/bin/python3"
.../node_modules/canvas install: gyp info spawn /Users/rahulkathuria/Documents/justbaat/optimus/tts/tts_env/bin/python3
.../node_modules/canvas install: gyp info spawn args [
.../node_modules/canvas install: gyp info spawn args '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
.../node_modules/canvas install: gyp info spawn args 'binding.gyp',
.../node_modules/canvas install: gyp info spawn args '-f',
.../node_modules/canvas install: gyp info spawn args 'make',
.../node_modules/canvas install: gyp info spawn args '-I',
.../node_modules/canvas install: gyp info spawn args '/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/canvas@2.11.2_encoding@0.1.13/node_modules/canvas/build/config.gypi',
.../node_modules/canvas install: gyp info spawn args '-I',
.../node_modules/canvas install: gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
.../node_modules/canvas install: gyp info spawn args '-I',
.../node_modules/canvas install: gyp info spawn args '/Users/rahulkathuria/Library/Caches/node-gyp/22.4.1/include/node/common.gypi',
.../node_modules/canvas install: gyp info spawn args '-Dlibrary=shared_library',
.../node_modules/canvas install: gyp info spawn args '-Dvisibility=default',
.../node_modules/canvas install: gyp info spawn args '-Dnode_root_dir=/Users/rahulkathuria/Library/Caches/node-gyp/22.4.1',
.../node_modules/canvas install: gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
.../node_modules/canvas install: gyp info spawn args '-Dnode_lib_file=/Users/rahulkathuria/Library/Caches/node-gyp/22.4.1/<(target_arch)/node.lib',
.../node_modules/canvas install: gyp info spawn args '-Dmodule_root_dir=/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/canvas@2.11.2_encoding@0.1.13/node_modules/canvas',
.../node_modules/canvas install: gyp info spawn args '-Dnode_engine=v8',
.../node_modules/canvas install: gyp info spawn args '--depth=.',
.../node_modules/canvas install: gyp info spawn args '--no-parallel',
.../node_modules/canvas install: gyp info spawn args '--generator-output',
.../node_modules/canvas install: gyp info spawn args 'build',
.../node_modules/canvas install: gyp info spawn args '-Goutput_dir=.'
.../node_modules/canvas install: gyp info spawn args ]
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn /Users/rahulkathuria/Documents/justbaat/optimus/tts/tts_env/bin/python3
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args [
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/node-gyp@9.4.1/node_modules/node-gyp/gyp/gyp_main.py',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   'binding.gyp',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-f',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   'make',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-I',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/gl@5.0.3/node_modules/gl/build/config.gypi',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-I',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/node-gyp@9.4.1/node_modules/node-gyp/addon.gypi',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-I',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '/Users/rahulkathuria/Library/Caches/node-gyp/22.4.1/include/node/common.gypi',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Dlibrary=shared_library',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Dvisibility=default',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Dnode_root_dir=/Users/rahulkathuria/Library/Caches/node-gyp/22.4.1',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Dnode_gyp_dir=/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/node-gyp@9.4.1/node_modules/node-gyp',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Dnode_lib_file=/Users/rahulkathuria/Library/Caches/node-gyp/22.4.1/<(target_arch)/node.lib',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Dmodule_root_dir=/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/gl@5.0.3/node_modules/gl',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Dnode_engine=v8',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '--depth=.',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '--no-parallel',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '--generator-output',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   'build',
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args   '-Goutput_dir=.'
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp info spawn args ]
.../.pnpm/gl@5.0.3/node_modules/gl install: /bin/sh: python: command not found
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp: Call to 'python commit_id.py check ..' returned exit status 127 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! configure error 
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! stack Error: `gyp` failed with exit code: 1
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! stack     at ChildProcess.onCpExit (/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/node-gyp@9.4.1/node_modules/node-gyp/lib/configure.js:325:16)
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! System Darwin 23.5.0
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! command "/usr/local/Cellar/node/22.4.1/bin/node" "/Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/node-gyp@9.4.1/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! cwd /Users/rahulkathuria/Documents/justbaat/layerhub-renderer/node_modules/.pnpm/gl@5.0.3/node_modules/gl
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! node -v v22.4.1
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! node-gyp -v v9.4.1
.../.pnpm/gl@5.0.3/node_modules/gl install: gyp ERR! not ok 
.../.pnpm/gl@5.0.3/node_modules/gl install: Failed
 ELIFECYCLE  Command failed with exit code 1.

Please help!

Did you open an issue at https://github.com/Automattic/node-canvas ?

Did you do xcode-select --install as discussed in README.md and in https://www.npmjs.com/package/canvas ?

Did you do the brew install discussed in https://www.npmjs.com/package/canvas ?

https://github.com/nodejs/node-gyp/blob/main/docs/README.md#node-pre-gyp-is-no-longer-maintained is a problem that we are trying to fix.

On the error message:

.../.pnpm/gl@5.0.3/node_modules/gl install: /bin/sh: python: command not found

You might try (all on one line):
% python=python3 <your command>

@cclauss yes, did all the steps
Automattic/node-canvas#2401

Also did % python=python3 command

Downgraded node from 22 to 20 and ugraded python from 3.9 to 3.12 for the canvas as mentioned in their issues related to installation guide but still no luck

hey I also had this issue, changing the Python version to 3.9.13 fixed it for me

Changing from what version to v3.9.13?

amcc commented

none of this worked for me, however going here and following the compiling steps (for Mac OS X in my case) worked perfectly: https://www.npmjs.com/package/canvas