Of course you're getting that error when opening a local file directly. You need to use a web server. On itch.io you already have one by definition, so it should work.
This is what I use to turn a folder on my machine into a localhost:3000 site: https://www.npmjs.com/package/http-server