canvas2image icon indicating copy to clipboard operation
canvas2image copied to clipboard

canvas2image npm not working

Open keshav1007 opened this issue 7 years ago • 2 comments

After installing canvas2image npm. I am getting the following error:

TypeError: Canvas2Image.saveAsPNG is not a function

keshav1007 avatar Nov 15 '17 12:11 keshav1007

the reason why using npm doesn't work is that the node_module 'canvas2image' only contains the 'var Canvas2image=function(){...' . you could replace 'module.exports=function(){...' instead of ''var Canvas2image=function(){...' in the node_module js file 'canvas2image.js', then using 'require()' does work.

mapkab avatar Nov 21 '17 06:11 mapkab

I created a fork, that uses ES6 modules so you can import it: https://github.com/TessyPowder/canvas2image-2

JonathanTreffler avatar Aug 02 '20 22:08 JonathanTreffler