In my case, I was using a javascript library and loading a theme file as part of the configuration. I misspelled the path to the file, which is what caused all of this. Why didn't it give me a better error message? Because I have my website set up to redirect all 404s to the homepage. So it tried to interpret my homepage HTML as the js theme file.
If you get a strange error like this, there's a good chance that you just made a typo.
If you redirect 404s to the homepage, it would probably be a good idea to disable it during development.