HTML exports not working

Hi everyone, I did 3 games with GDevelop and 2 of them have an error in the export. When I export the last game that I did to HTML with the Export to a website option, it shows a black screen and I get this error in the JS console.

code.js:4 Uncaught TypeError: Cannot read property 'localStorage' of undefined at code.js:4 code.js:2 Uncaught TypeError: Cannot read property 'variables' of undefined at new gdjs.RuntimeGame (code.js:2) at index.html:37 at index.html:50

I have 2 scenes, the menu scene with this code:


and the game scene with this code:

I hope someone can help me because it is very frustrating that I spend hours making a game and at the end I can’t export it.

In case it does work in preview, try to hard refresh your browser.
In case you try to open the exported HTML5 game directly on your computer, try it with multiple browsers.
In case it still doesn’t work and you are using Cocod2D-js, try the default option which is using Pixi.js

In case it doesn’t work in preview either, check any Javascript event for any syntax error. If you don’t use any JS event or there is definitely no error, check if you have spelled all your variables correctly, preferably use the scene and global variable editors to add all variable to the list you are using so GD can define the variables before use. Also make sure you don’t use wrong values somewhere like a number for a string variable or string for integer variable.
Also check all the storage action events if everything is spelled correctly, in case you don’t, try to open and close files before and after reading-writing values.
In case you still getting the same error messages and you are using the default export option, it might be a bug I’m not sure but in case an HTML5 export does not run for me, this is the most common reasons that normally causing problems.

Hi, it works on the preview. I had already reloaded the browser and tried it in chrome, firefox and IE. Also I tried cocos and pixi. I don’t use any JS written by me, and I don’t have storage actions and I checked I the variables :frowning: . I hope it is a bug from GD4, I will try GD5 if I can’t find the reason. Thanks

Try a common slash instead an inverse one in the sound file path? :confused:

No, same problem.

Well, this will be a problem. My game uses physics and GD5 does not include physics :frowning:

Well, 4ian did not made it official yet (maybe forget not sure why) but you can download beta22 which is including physics:
github.com/4ian/GD/releases/

Note that, at least on my end, there is a bug with the scene editor in beta22. Sometime objects not rendered in the editor but the object is there and will be rendered again once you press save or switch to events then back to scene. Maybe this is the reason why this version is not official yet. But so far I didn’t experienced the problem in exported games but only in the editor.