saveCanvas is in the p5 reference here:
https://p5js.org/reference/#/p5/saveCanvas
This will export the canvas as a bit map (i.e. a file made of pixels like a png or jpeg)
// this will export your canvas as a jpeg named myCanvas.jpg
saveCanvas('myCanvas', 'jpg');
You'll find the above works perfectly well - its simpler than the actual p5js reference example.