How to handle errors arising from Canvas compilation?
See original GitHub issueI get errors trying to add vega-embed to my project on mac osx 10.13 (high sierra)
Anyone have any ideas?
Chads-MBP:kinetix-ui chadbr$ yarn add vega-embed
yarn add v1.0.0
[1/5] π Validating package.json...
[2/5] π Resolving packages...
warning object-keys@0.4.0:
[3/5] π Fetching packages...
[4/5] π Linking dependencies...
warning "@angular/flex-layout@2.0.0-rc.1" has incorrect peer dependency "@angular/common@^2.2.3".
warning "@angular/flex-layout@2.0.0-rc.1" has incorrect peer dependency "@angular/core@^2.2.3".
warning "@angular/flex-layout@2.0.0-rc.1" has incorrect peer dependency "zone.js@^0.7.2".
warning "@ngtools/webpack@1.5.5" has incorrect peer dependency "enhanced-resolve@^3.1.0".
warning "@ngtools/webpack@1.5.5" has incorrect peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "extract-text-webpack-plugin@2.1.2" has incorrect peer dependency "webpack@^2.2.0".
warning "html-webpack-plugin@2.30.1" has incorrect peer dependency "webpack@1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3".
warning "less-loader@4.0.5" has incorrect peer dependency "less@^2.3.1".
warning "less-loader@4.0.5" has incorrect peer dependency "webpack@^2.0.0 || ^3.0.0".
warning "sass-loader@6.0.6" has incorrect peer dependency "node-sass@^4.0.0".
warning "sass-loader@6.0.6" has incorrect peer dependency "webpack@^2.0.0 || >= 3.0.0-rc.0 || ^3.0.0".
warning "stylus-loader@3.0.1" has incorrect peer dependency "stylus@>=0.52.4".
warning "url-loader@0.5.9" has incorrect peer dependency "file-loader@*".
warning "webpack-dev-middleware@1.12.0" has incorrect peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
warning "webpack-dev-server@2.4.5" has incorrect peer dependency "webpack@^2.2.0".
warning "ajv-keywords@1.5.1" has incorrect peer dependency "ajv@>=4.10.0".
[5/5] π Building fresh packages...
[1/2] β canvas: '-Goutput_dir=.' ]
[2/2] β canvas-prebuilt: node-pre-gyp http GET https://github.com/chearon/node-canvas-prebuilt/releases/download/v1.6.0/canvas-prebuil
[-/2] β waiting...
[-/2] β waiting...
warning Error running install script for optional dependency: "/Users/chadbr/dev/vsts/kinetix-
ui/node_modules/canvas: Command failed.\nExit code: 1\nCommand: node-gyp rebuild\nArguments:
\nDirectory: /Users/chadbr/dev/vsts/kinetix-ui/node_modules/canvas\nOutput:\ngyp info it worked if
it ends with ok\ngyp info using node-gyp@3.6.2\ngyp info using node@8.7.0 | darwin | x64\ngyp
info spawn /Library/Frameworks/Python.framework/Versions/2.7/bin/python2\ngyp info spawn args [
'/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',\ngyp info spawn args
'binding.gyp',\ngyp info spawn args '-f',\ngyp info spawn args 'make',\ngyp info spawn args '-
I',\ngyp info spawn args '/Users/chadbr/dev/vsts/kinetix-
ui/node_modules/canvas/build/config.gypi',\ngyp info spawn args '-I',\ngyp info spawn args
'/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',\ngyp info spawn args '-
I',\ngyp info spawn args '/Users/chadbr/.node-gyp/8.7.0/include/node/common.gypi',\ngyp info
spawn args '-Dlibrary=shared_library',\ngyp info spawn args '-Dvisibility=default',\ngyp info
spawn args '-Dnode_root_dir=/Users/chadbr/.node-gyp/8.7.0',\ngyp info spawn args '-
Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',\ngyp info spawn args
'-Dnode_lib_file=/Users/chadbr/.node-gyp/8.7.0/<(target_arch)/node.lib',\ngyp info spawn args '-
Dmodule_root_dir=/Users/chadbr/dev/vsts/kinetix-ui/node_modules/canvas',\ngyp info spawn args
'-Dnode_engine=v8',\ngyp info spawn args '--depth=.',\ngyp info spawn args '--no-parallel',\ngyp
info spawn args '--generator-output',\ngyp info spawn args 'build',\ngyp info spawn args '-
Goutput_dir=.' ]\n./util/has_lib.sh: line 31: pkg-config: command not found\ngyp: Call to
'./util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load
binding.gyp\ngyp ERR! configure error \ngyp ERR! stack Error: `gyp` failed with exit code: 1\ngyp
ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-
gyp/lib/configure.js:336:16)\ngyp ERR! stack at emitTwo (events.js:125:13)\ngyp ERR! stack at
ChildProcess.emit (events.js:213:7)\ngyp ERR! stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:200:12success Saved lockfile.
success Saved 78 new dependencies.
ββ brfs@1.4.3
ββ buffer-equal@0.0.1
ββ canvas-prebuilt@1.6.0
ββ compare-versions@3.1.0
ββ d3-array@1.2.1
ββ d3-collection@1.0.4
ββ d3-color@1.0.3
ββ d3-contour@1.1.1
ββ d3-dispatch@1.0.3
ββ d3-dsv@1.0.7
ββ d3-force@1.1.0
ββ d3-format@1.2.0
ββ d3-geo-projection@0.2.16
ββ d3-geo@1.9.0
ββ d3-hierarchy@1.1.5
ββ d3-interpolate@1.1.5
ββ d3-path@1.0.5
ββ d3-quadtree@1.0.3
ββ d3-queue@2.0.3
ββ d3-request@1.0.6
ββ d3-scale-chromatic@1.1.1
ββ d3-scale@1.0.6
ββ d3-selection@1.1.0
ββ d3-shape@1.2.0
ββ d3-time-format@2.1.0
ββ d3-time@1.0.7
ββ d3-timer@1.0.7
ββ d3-voronoi@1.1.2
ββ d3@3.5.17
ββ escodegen@1.3.3
ββ estraverse@1.5.1
ββ falafel@2.1.0
ββ foreach@2.0.5
ββ get-stream@3.0.0
ββ locate-path@2.0.0
ββ mem@1.1.0
ββ object-inspect@0.4.0
ββ object-keys@0.4.0
ββ p-finally@1.0.0
ββ p-limit@1.1.0
ββ p-locate@2.0.0
ββ quote-stream@1.0.2
ββ rw@1.3.3
ββ shallow-copy@0.0.1
ββ shapefile@0.3.1
ββ shebang-command@1.2.0
ββ shebang-regex@1.0.0
ββ static-eval@0.2.4
ββ static-module@1.5.0
ββ through2@0.4.2
ββ topojson@1.6.27
ββ vega-crossfilter@2.0.0
ββ vega-dataflow@3.0.3
ββ vega-datasets@1.10.0
ββ vega-embed@3.0.0-beta.20
ββ vega-encode@2.0.4
ββ vega-event-selector@2.0.0
ββ vega-expression@2.3.1
ββ vega-force@2.0.0
ββ vega-geo@2.1.1
ββ vega-hierarchy@2.1.0
ββ vega-lite@2.0.0-rc4
ββ vega-loader@2.0.2
ββ vega-parser@2.3.0
ββ vega-projection@1.0.0
ββ vega-runtime@2.0.0
ββ vega-scale@2.1.0
ββ vega-scenegraph@2.0.4
ββ vega-schema-url-parser@1.0.0-beta.3
ββ vega-statistics@1.2.1
ββ vega-transforms@1.1.1
ββ vega-util@1.6.0
ββ vega-view-transforms@1.1.0
ββ vega-view@2.0.3
ββ vega-voronoi@2.0.0
ββ vega-wordcloud@2.0.2
ββ vega@3.0.6
ββ xmlhttprequest@1.8.0
β¨ Done in 15.24s.
Chads-MBP:kinetix-ui chadbr$
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Power Apps Patch Function Error Handling - Matthew Devaney
First, we use the Errors function to check if there were any problems during the latest patch. Errors outputs a table so we'll...
Read more >Node Canvas throwing error when running project
If that fails, go to node_modules/canvas and run npm install --build-from-source , which will compile the C++ addon and output the corect canvas...
Read more >Introduction to Error Handling - Make
Basics Β· Error handler route Β· To add an error handler route to a module (let us call it Module X), right-click (or...
Read more >Errors - discord.js Guide
JavaScript errors are thrown by node itself or by discord.js. These errors can easily be fixed by looking at the type of error...
Read more >C++ Exceptions - W3Schools
Example. try { // Block of code to try throw exception; // Throw an exception when a problem arise } catch () {...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

hurrah! and good golly β
This fixed it:
I found that in the canvas-prebuilt/canvas readmeβ¦
thatβs a long roadβ¦ π
is it really needed if itβs an optional install?
Thanks - Chad
Canvas is βoptionalβ in the sense that Vega can run without it.
However, Canvas is used to compute font metrics. If it is not available, Vega falls back on some approximations that in some cases can lead to different bounding box and downstream layout calculationsβ¦
Various users over the years requested that it be made optional to enable graceful degradation when canvas installation fails, or when one is only concerned about browser deployment (at which point HTML canvas is available).
In any case, Iβm glad you found the solution!