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

node-canvas wont install, what so ever #2387

Closed
1 task done
0wv opened this issue May 25, 2024 · 10 comments
Closed
1 task done

node-canvas wont install, what so ever #2387

0wv opened this issue May 25, 2024 · 10 comments

Comments

@0wv
Copy link

0wv commented May 25, 2024

Issue or Feature

warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^7.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^7.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^6.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^7.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^6.0.1"
warning captcha-canvas > canvas > @mapbox/node-pre-gyp > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning captcha-canvas > canvas > @mapbox/node-pre-gyp > npmlog@5.0.1: This package is no longer supported.
warning captcha-canvas > canvas > @mapbox/node-pre-gyp > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning captcha-canvas > canvas > @mapbox/node-pre-gyp > npmlog > gauge@3.0.2: This package is no longer supported.
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^6.0.1"
warning captcha-canvas > canvas > @mapbox/node-pre-gyp > npmlog > are-we-there-yet@2.0.0: This package is no longer supported.
warning captcha-canvas > canvas > @mapbox/node-pre-gyp > rimraf > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^6.0.1"
[3/5] Fetching packages...
warning Pattern ["string-width@^4.1.0"] is trying to unpack in the same destination "C:\\Users\\Graham\\AppData\\Local\\Yarn\\Cache\\v6\\npm-string-width-cjs-4.2.3-269c7117d27b05ad2e536830a8ec895ef9c6d010-integrity\\node_modules\\string-width-cjs" as pattern ["string-width-cjs@npm:string-width@^4.2.0"]. This could result in non-deterministic behavior, skipping.
[4/5] Linking dependencies...
[5/5] Building fresh packages...
[1/2]  canvas
error E:\Programming\Typescript\fiftyone\node_modules\captcha-canvas\node_modules\canvas: Command failed.
Exit code: 7
Command: node-pre-gyp install --fallback-to-build --update-binary
Arguments:
Directory: E:\Programming\Typescript\fiftyone\node_modules\captcha-canvas\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.2.0 | win32 | x64
(node:29036) [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-win32-unknown-x64.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-win32-unknown-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@22.2.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-win32-unknown-x64.tar.gz
node-pre-gyp ERR! UNCAUGHT EXCEPTION
node-pre-gyp ERR! stack Error: spawn EINVAL
node-pre-gyp ERR! stack     at ChildProcess.spawn (node:internal/child_process:421:11)
node-pre-gyp ERR! stack     at Object.spawn (node:child_process:760:9)
node-pre-gyp ERR! stack     at module.exports.run_gyp (E:\Programming\Typescript\fiftyone\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:80:18)
node-pre-gyp ERR! stack     at build (E:\Programming\Typescript\fiftyone\node_modules\@mapbox\node-pre-gyp\lib\build.js:41:13)
node-pre-gyp ERR! stack     at self.commands.<computed> [as build] (E:\Programming\Typescript\fiftyone\node_modules\@mapbox\node-pre-gyp\lib\node-pre-gyp.js:86:37)
node-pre-gyp ERR! stack     at run (E:\Programming\Typescript\fiftyone\node_modules\@mapbox\node-pre-gyp\lib\main.js:81:30)
node-pre-gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
node-pre-gyp ERR! System Windows_NT 10.0.19045
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\Programming\\Typescript\\fiftyone\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
node-pre-gyp ERR! cwd E:\Programming\Typescript\fiftyone\node_modules\captcha-canvas\node_modules\canvas
node-pre-gyp ERR! node -v v22.2.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.11

Steps to Reproduce

using yarn add node-canvas

NOTE: warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^7.0.1"
is because i have to use 6.0.0 otherwise i get

const stripAnsi = require('strip-ansi');
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module E:\Programming\Typescript\fiftyone\node_modules\strip-ansi\index.js from E:\Programming\Typescript\fiftyone\node_modules\string-width\index.js not supported.
Instead change the require of E:\Programming\Typescript\fiftyone\node_modules\strip-ansi\index.js in E:\Programming\Typescript\fiftyone\node_modules\string-width\index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (E:\Programming\Typescript\fiftyone\node_modules\string-width\index.js:2:19) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v22.2.0

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas):
PS E:\Programming\Typescript\fiftyone> yarn list canvas
yarn list v1.22.19
⠁ (node:11572) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^7.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^7.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^6.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^7.0.1"
warning Resolution field "strip-ansi@6.0.0" is incompatible with requested version "strip-ansi@^6.0.1"
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ canvas@3.0.0
Done in 1.87s.
  • Environment (e.g. node 20.9.0 on macOS 14.1.1):
  • node version - 10.8.0
@Elitezen
Copy link

I get the following error when trying to install via NPM on Node version 22.1.0:

npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated npmlog@5.0.1: This package is no longer supported.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated are-we-there-yet@2.0.0: This package is no longer supported.
npm warn deprecated gauge@3.0.2: This package is no longer supported.
npm error code 1
npm error path C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build --update-binary
npm error Warning: Missing input files:
npm error C:\GTK\bin\libpangocairo-1.0-0.dll
npm error C:\GTK\bin\libgobject-2.0-0.dll
npm error C:\GTK\bin\libpng14-14.dll
npm error C:\GTK\bin\libfreetype-6.dll
npm error C:\GTK\bin\libgmodule-2.0-0.dll
npm error C:\GTK\bin\libintl-8.dll
npm error C:\GTK\bin\libpango-1.0-0.dll
npm error C:\GTK\bin\zlib1.dll
npm error C:\GTK\bin\libexpat-1.dll
npm error C:\GTK\bin\libpangowin32-1.0-0.dll
npm error C:\GTK\bin\libcairo-2.dll
npm error C:\GTK\bin\libpangoft2-1.0-0.dll
npm error C:\GTK\bin\libglib-2.0-0.dll
npm error C:\GTK\bin\libfontconfig-1.dll
npm error C:\GTK\bin\libgthread-2.0-0.dll
npm error Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
npm error
npm error   Backend.cc
npm error C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas\src\backend\Backend.h(3,10): fatal  error C1083: Cannot open include file: 'cairo.h': No such file or directory [C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas\build\canvas.vcxproj]
npm error Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --update-binary --module=C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas\build\Release\canvas.node --module_name=canvas --module_path=C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas\build\Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v127' (1)
npm error node-pre-gyp info it worked if it ends with ok
npm error node-pre-gyp info using node-pre-gyp@1.0.11
npm error node-pre-gyp info using node@22.1.0 | win32 | x64
npm error (node:5796) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
npm error (Use `node --trace-deprecation ...` to show where the warning was created)
npm error node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v127-win32-unknown-x64.tar.gz
npm error 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-win32-unknown-x64.tar.gz
npm error node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@22.1.0 (node-v127 ABI, unknown) (falling back to source compile with node-gyp)
npm error 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-win32-unknown-x64.tar.gz
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.1.0
npm error gyp info using node@22.1.0 | win32 | x64
npm error gyp info ok
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.1.0
npm error gyp info using node@22.1.0 | win32 | x64
npm error gyp info find Python using Python version 3.11.9 found at "C:\Users\deval\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe"
npm error gyp info find VS using VS2022 (17.6.33815.320) found at:
npm error gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm error gyp info find VS run with --verbose for detailed information
npm error gyp info spawn C:\Users\deval\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe
npm error gyp info spawn args [
npm error gyp info spawn args 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'msvs',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\\Users\\deval\\Documents\\workspace\\text-on-gif\\node_modules\\canvas\\build\\config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\\Users\\deval\\AppData\\Local\\node-gyp\\Cache\\22.1.0\\include\\node\\common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=C:\\Users\\deval\\AppData\\Local\\node-gyp\\Cache\\22.1.0',
npm error gyp info spawn args '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\deval\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\22.1.0\\\\<(target_arch)\\\\node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=C:\\Users\\deval\\Documents\\workspace\\text-on-gif\\node_modules\\canvas',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'C:\\Users\\deval\\Documents\\workspace\\text-on-gif\\node_modules\\canvas\\build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info ok
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.1.0
npm error gyp info using node@22.1.0 | win32 | x64
npm error gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
npm error gyp info spawn args [
npm error gyp info spawn args 'build\\binding.sln',
npm error gyp info spawn args '/clp:Verbosity=minimal',
npm error gyp info spawn args '/nologo',
npm error gyp info spawn args '/p:Configuration=Release;Platform=x64'
npm error gyp info spawn args ]
npm error gyp ERR! build error
npm error gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm error gyp ERR! stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:209:23)
npm error gyp ERR! stack at ChildProcess.emit (node:events:520:28)
npm error gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm error gyp ERR! System Windows_NT 10.0.22631
npm error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--update-binary" "--module=C:\\Users\\deval\\Documents\\workspace\\text-on-gif\\node_modules\\canvas\\build\\Release\\canvas.node" "--module_name=canvas" "--module_path=C:\\Users\\deval\\Documents\\workspace\\text-on-gif\\node_modules\\canvas\\build\\Release" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v127"
npm error gyp ERR! cwd C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas
npm error gyp ERR! node -v v22.1.0
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok
npm error node-pre-gyp ERR! build error
npm error node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --update-binary --module=C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas\build\Release\canvas.node --module_name=canvas --module_path=C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas\build\Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v127' (1)
npm error node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\deval\Documents\workspace\text-on-gif\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
npm error node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
npm error node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
npm error node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm error node-pre-gyp ERR! System Windows_NT 10.0.22631
npm error node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\deval\\Documents\\workspace\\text-on-gif\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
npm error node-pre-gyp ERR! cwd C:\Users\deval\Documents\workspace\text-on-gif\node_modules\canvas
npm error node-pre-gyp ERR! node -v v22.1.0
npm error node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm error node-pre-gyp ERR! not ok

npm error A complete log of this run can be found in: C:\Users\deval\AppData\Local\npm-cache\_logs\2024-05-27T00_53_23_520Z-debug-0.log

@katherine95
Copy link

To fix node-canvas issue on Mac, I ran the following steps:-

Fix node-canvas
brew reinstall python
python3 -m venv myenv
source myenv/bin/activate
pip install setuptools
deactivate
export PYTHON=$(which python3)

@0wv
Copy link
Author

0wv commented May 28, 2024

To fix node-canvas issue on Mac, I ran the following steps:-

Fix node-canvas brew reinstall python python3 -m venv myenv source myenv/bin/activate pip install setuptools deactivate export PYTHON=$(which python3)

I'm on windows 😢

@letharion
Copy link

Try node 20 instead of 22.
See #2377

@0wv
Copy link
Author

0wv commented May 30, 2024

Try node 20 instead of 22. See #2377

Is there an easy way to go down to node 20 without using nvm?

@letharion
Copy link

Is there an easy way to go down to node 20 without using nvm?

The answer probably depends on how you installed node in the first place. There's lots of tiny details that can't be covered in this issue. I suggest you look at the instructions that come with your original node installation. But if struggle to downgrade to downgrade, then trying to run canvas from master, either as a direct dependency, or as an override is an option.
As a last ditch effort, one could look into patching canvas, but that sort of thing is not for the faint of heart.

Nvm is likely your best option.

@jacobp100
Copy link

On macOS, If you see

ModuleNotFoundError: No module named 'distutils'

run

brew install python-setuptools

cunneen added a commit to cunneen/node-canvas that referenced this issue Jun 7, 2024
Added `python@3.12` and `python-setuptools` to instructions as per comments in Automattic#2371 and Automattic#2387
@keyp-dev
Copy link

When will nodejs 22.2.0 be supported?

@aaronplanell
Copy link

Same for https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v115-linux-glibc-x64.tar.gz

Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.9
node-pre-gyp info using node@20.11.0 | linux | x64
node-pre-gyp info check checked for "/home/redpoints/projects/redpoints-connector-common/node_modules/canvas/build/Release/canvas.node" (not found)
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v115-linux-glibc-x64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v115-linux-glibc-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.9.1 and node@20.11.0 (node-v115 ABI, glibc) (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.9.1/canvas-v2.9.1-node-v115-linux-glibc-x64.tar.gz 

@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.

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

8 participants