WebGL build error :Uncaught SyntaxError: Unexpected token < || UnityLoader.js is not a function (SOLVED)

I have uploaded my game to a webhost unoeuro woth the index.html the build d a templatedata folders and then launching the index.html I get the aforementioned error.

I google a bit and it seems its because the .htaccess file needs to be editted to fix this however, I can find no such file in my build and therefore I cannot fix this. wondering if anyone could guide me a bit here?

thanks.

So I solved this issue, But it has been really frustrating as many of the people discussing this issue really assume a lot of their readers know a great deal about uploading files to a webserver. so I am going to be wrtting the very basics here for anyone having this issue:

If you have bought a webhotel, a website where you can place files. and you have uploaded your game to that website in webgl. You are trying to upload the (1) Index.html file, which is the main file that runs the game, (2) the templateData folder that has all the graphics for the website that unity creates for you, and (3) the Build folder that contains all the data for your game.

The issue is that all the ending of the files cannot be read by the webserver as they do not know what a “.unityweb” file is.

This needs to be told to the server so it knows what to do with them. On the web the files are recognized by something called a “MIME” type. you can read a good post on stack overflow about it here:

https://stackoverflow.com/questions/3828352/what-is-a-mime-type

In order to do this you will need to create your own extra file that unity does not create for you by default. I will run you through it here.

  • Open a new notepad text file.

  • Save this file as “web.config”
    somewhere you can find it, preferably
    in your game folder next to your
    index.html file

  • close notepad

  • doubleclick the web.config file and
    it should open in the integrated
    development environment (IDE) of your
    choice. most likely visual studio.

  • paste in the following code:

     <configuration>
        <system.webServer>
           <staticContent>
       
              <mimeMap fileExtension=".unityweb" mimeType ="TYPE/SUBTYPE" />
    
           </staticContent>
        </system.webServer> 
     </configuration>
    
  • Save.

  • upload this file next to your
    index.html file.

  • cheer!

hope this helps someone. I would have killed for this information.


Basically this file is just letting the website know what MIME type “unityweb” is, and now it should know what to do with it.

Thank you so much! I have been looking for the answer to this for about 3 hours now, and this solution works. Thank you.,Thank you so much. I have been trying to do this for 3 hours now, and this is a real solution. Thank you.

I would like to add a solution that works for asp.net hosting, since the web.config doesn’t work. The following stackoverflow solution discribes how to add mime types in asp.net.
c# - How to add Mime Types in ASP.NET Core - Stack Overflow

Thank you!!! @SteenPetersen

If your webhosting is linux / apache based
Add the following line into the ‘.htaccess’ file

AddType TYPE/SUBTYPE unityweb

,If your webhosting is linux / apache based:

Add the following line into the ‘.htaccess’ file

AddType TYPE/SUBTYPE unityweb

Very useful!
I was so close to solution on official pages.
Go(o)d Rule: while doing something new and complex, take all the time (and patience) to learn it.

Manual: WebGL Building

Manual: WebGL Deploying

With recent Unity versions, the WebGL build files no longer have the .unityweb extension. the extensions are just .data, .framework.js and .wasm.

I am having the exact same issue. What should I do if my files don’t end with .unityweb? should I add a line in the web.config file for each extension?