Skip to content

[C1083 Cannot open include file: 'cairo.h'] Can not use canvas and electron at the same time #1810

@TheArmagan

Description

@TheArmagan

e a general summary of the issue in the Title above -->

Issue or Feature

Cannot use canvas and electron same time.

Steps to Reproduce

I just ran these commands:

  • yarn global add electron
  • yarn global add electron-rebuild
  • yarn add electron
  • electron-rebuild - Success
  • yarn add canvas
  • electron-rebuild - Error

The command log:

D:\BDT\Desktop\draw-cpu-usage\node_modules\canvas>electron-rebuild
⠴ Building module: canvas, Completed: 0gyp info find Python using Python version 3.9.5 found at "C:\Users\BDT\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe"
⠏ Building module: canvas, Completed: 0gyp info find VS using VS2019 (16.9.31112.23) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
⠋ Building module: canvas, Completed: 0gyp info spawn C:\Users\BDT\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\BDT\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\BDT\\Desktop\\draw-cpu-usage\\node_modules\\canvas\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\BDT\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\BDT\\.electron-gyp\\12.0.9\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\BDT\\.electron-gyp\\12.0.9',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\BDT\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\BDT\\\\.electron-gyp\\\\12.0.9\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=D:\\BDT\\Desktop\\draw-cpu-usage\\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   'D:\\BDT\\Desktop\\draw-cpu-usage\\node_modules\\canvas\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
⠼ Building module: canvas, Completed: 0Warning: Missing input files:
C:\GTK\bin\libfreetype-6.dll
C:\GTK\bin\libcairo-2.dll
C:\GTK\bin\zlib1.dll
C:\GTK\bin\libpangoft2-1.0-0.dll
C:\GTK\bin\libfontconfig-1.dll
C:\GTK\bin\libpng14-14.dll
C:\GTK\bin\libpangocairo-1.0-0.dll
C:\GTK\bin\libgmodule-2.0-0.dll
C:\GTK\bin\libpango-1.0-0.dll
C:\GTK\bin\libintl-8.dll
C:\GTK\bin\libgobject-2.0-0.dll
C:\GTK\bin\libexpat-1.dll
C:\GTK\bin\libpangowin32-1.0-0.dll
C:\GTK\bin\libglib-2.0-0.dll
C:\GTK\bin\libgthread-2.0-0.dll
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64',
gyp info spawn args   map: [Function (anonymous)]
gyp info spawn args ]
⠴ Building module: canvas, Completed: 0Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
⠏ Building module: canvas, Completed: 0  Backend.cc
⠋ Building module: canvas, Completed: 0D:\BDT\Desktop\draw-cpu-usage\node_modules\canvas\src\backend\Backend.h(3,10): fatal error C1083: Cannot open include f
ile: 'cairo.h': No such file or directory [D:\BDT\Desktop\draw-cpu-usage\node_modules\canvas\build\canvas.vcxproj]
✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild 'D:\BDT\Desktop\draw-cpu-usage\node_modules\canvas'.
Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1



Error: node-gyp failed to rebuild 'D:\BDT\Desktop\draw-cpu-usage\node_modules\canvas'.
Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1


    at ModuleRebuilder.rebuildNodeGypModule (C:\Users\BDT\AppData\Local\Yarn\Data\global\node_modules\electron-rebuild\lib\src\module-rebuilder.js:193:19)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Rebuilder.rebuildModuleAt (C:\Users\BDT\AppData\Local\Yarn\Data\global\node_modules\electron-rebuild\lib\src\rebuild.js:190:9)
    at async Rebuilder.rebuild (C:\Users\BDT\AppData\Local\Yarn\Data\global\node_modules\electron-rebuild\lib\src\rebuild.js:152:17)
    at async C:\Users\BDT\AppData\Local\Yarn\Data\global\node_modules\electron-rebuild\lib\src\cli.js:146:9

const { createCanvas } = require("canvas");
const { app, Tray, NativeImage } = require("electron");

Your Environment

  • Version of node-canvas: 2.8.0
  • Environment: v14.17.0 on Windows 10 19042.985
  • Electron Version: v12.0.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions