error when using node-canvas alpha.8
See original GitHub issuemy package.json versions
“canvas”: “2.0.0-alpha.8” “chart.js”: “^2.7.1”, “chartjs-node”: “^1.6.0”,
When using "canvas": "^2.0.0-alpha.2",
node-chartjs works like a charm, when using "canvas": "^2.0.0-alpha.8",
item is null in acquireContext so item.length errors in platform.dom.js
acquireContext: function(item, config) {
if (typeof item === 'string') {
item = document.getElementById(item);
} else if (item.length) {
// Support for array based queries (such as jQuery)
item = item[0];
}
if (item && item.canvas) {
// Support for any object associated to a canvas (including a context2d)
item = item.canvas;
}
// To prevent canvas fingerprinting, some add-ons undefine the getContext
// method, for example: https://github.com/kkapsner/CanvasBlocker
// https://github.com/chartjs/Chart.js/issues/2807
var context = item && item.getContext && item.getContext('2d');
// `instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when the item is
// inside an iframe or when running in a protected environment. We could guess the
// types from their toString() value but let's keep things flexible and assume it's
// a sufficient condition if the item has a context2D which has item as `canvas`.
// https://github.com/chartjs/Chart.js/issues/3887
// https://github.com/chartjs/Chart.js/issues/4102
// https://github.com/chartjs/Chart.js/issues/4152
if (context && context.canvas === item) {
initCanvas(item, config);
return context;
}
return null;
},
Can someone please help me and tell me what im doing wrong?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11
Top Results From Across the Web
Error running canvas on node.js v10.17 #1498 - GitHub
When trying to run canvas on node.js v10.17 I get this error: (node:22368) ... was compiled against a different Node.js version using
Read more >node-canvas - npm
node-canvas. This is the documentation for version 2.0.0-alpha. Alpha versions of 2.0 can be installed using npm install canvas@next .
Read more >node canvas on alpine within docker - Stack Overflow
OK, here's an answer--a way to install node-canvas v2.5 under the official node:10.16.0-alpine Docker image. As you probably know, the error ...
Read more >canvas-prebuilt | Yarn - Package Manager
This is a drop-in replacement for canvas that does not require any compiling. To use it just npm install canvas-prebuilt or replace canvas...
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 FreeTop 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
Top GitHub Comments
@gonnza thanks! I ended up downgrading to canvas 1.6.13 and that is working just fine. Thanks for the input, that definitely helped me out! 😃
bump, also having this problem with canvas 2.x, but resolves with older versions. Any updates on why this is happening with recent versions?
The error is: “Unhandled rejection TypeError: Cannot read property ‘length’ of null”.
Any better solutions than just downgrading the canvas version?