Why hello random n00b from the internet! Are you struggling to solve this issue too, and, like me, tried everything and are not getting it to work after looking at (and copying exactly) the code from the example listed at the example at export svg by dannyrozin -p5.js Web Editor ?
Well! Yes, you need to add the line including the js-svg script to the HTML, but a friendly note: the other includes from P5 are necessary. I am aware this sounds obvious, but if you are a dumb dumb like me you may have missed it, thinking that P5 was installed locally on your system via npm or something as you just installed the P5 extension into VS Code and thought that took care of it.
This is an incorrect assumption. Because I am a stoopid. Don’t be a stoopid like me. Be a smartie.
In the example page on the P5 browser playground, click on the file browser button (that I didn’t notice)
and note the entire header:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.1/p5.min.js"></script>
<script src="https://unpkg.com/p5.js-svg@1.3.1"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.1/addons/p5.dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.1/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />
</head>
<body>
<script src="sketch.js"></script>
</body>
</html>
I know you think you’ve added it correctly, just try it again. 1.5.1 I have found also works and is the latest version as of writing.
Hope this saves you, random traveller!