HTML compilation error.

I compilated my project for HTML and uploaded it to a web hosting. I get that error in the JS console and the screen is black.

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 sebastian-juego.000webhostapp.com/:37 at sebastian-juego.000webhostapp.com/:50

I opened the website and all in folder “src” is missing.
If you can export your game differently try it :slight_smile:

I dont know why the folder did not uploaded. Now I checked that all the files are in the server but I get more errors.

Failed to load resource: the server responded with a status of 404 () cocos2d-js-v3.10.js:1 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. _loadTxtSync @ cocos2d-js-v3.10.js:1 cocos2d-js-v3.10.js:11 Cocos2d-JS v3.10 /src/Extensions/PhysicsBehavior/box2djs/box2d.js:4 pre-main prep time: 1 ms main.js:2 Uncaught TypeError: Cannot read property 'isNative' of undefined at Object.cc.game.onStart (main.js:2) at Array.<anonymous> (cocos2d-js-v3.10.js:1) at cocos2d-js-v3.10.js:1 at Object.<anonymous> (cocos2d-js-v3.10.js:1) at HTMLScriptElement.<anonymous> (cocos2d-js-v3.10.js:1) cocos2d-js-v3.10.js:8 Uncaught TypeError: Cannot read property 'config' of undefined at calculateDeltaTime (cocos2d-js-v3.10.js:8) at c.drawScene (cocos2d-js-v3.10.js:8) at c.mainLoop (cocos2d-js-v3.10.js:8) at a (cocos2d-js-v3.10.js:1) /res/favicon.ico Failed to load resource: the server responded with a status of 404 () cocos2d-js-v3.10.js:4 Uncaught TypeError: cc.isFunction is not a function at Object.getHTMLElementPosition (cocos2d-js-v3.10.js:4) at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:4) cocos2d-js-v3.10.js:4 Uncaught TypeError: cc.isFunction is not a function at Object.getHTMLElementPosition (cocos2d-js-v3.10.js:4) at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:4) cocos2d-js-v3.10.js:4 Uncaught TypeError: cc.isFunction is not a function at Object.getHTMLElementPosition (cocos2d-js-v3.10.js:4) at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:4) cocos2d-js-v3.10.js:4 Uncaught TypeError: cc.isFunction is not a function at Object.getHTMLElementPosition (cocos2d-js-v3.10.js:4) at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:4) 3cocos2d-js-v3.10.js:11 Uncaught TypeError: Cannot read property 'dispatchEvent' of undefined at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:11) 3cocos2d-js-v3.10.js:11 Uncaught TypeError: Cannot read property 'dispatchEvent' of undefined at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:11) 11cocos2d-js-v3.10.js:4 Uncaught TypeError: cc.isFunction is not a function at Object.getHTMLElementPosition (cocos2d-js-v3.10.js:4) at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:4)

Have you tried to run the game locally on your PC using Firefox or Brackets for example?
If you tried it and you get the same error message, try using the default export which is using Pixi.js.
Cocos2D.js export is not stable at the moment if you plan to host the game only on a website Pixi.js is more reliable.

Maybe your webhost is blocking some files or requesting xhr which causes problems.

I exported some other projects and it worked, but I don’t know why that specific project does not work. Thanks.