Error: Cannot find module 'canvas'

I tried to run this code and got an error. Can you provide any tips to get this running?

var canvas = new (require("canvas"))(200, 200);
var context = canvas.getContext("2d");
context.arc(100, 100, 100, 0, 2 * Math.PI, false);

This code is taken directly from an example on the RunKit homepage:

Sorry about that, there was an issue with some packages when we added Node 8 support that caused them to be unavailable in all engines. I’ve fixed the issue for Canvas ( and it should work now!

- Randy

1 Like