ReferenceError: BABYLON is not defined

Hello,

I started with this template First Steps - Babylon.js Documentation, my problem is sometimes it works fine in the browser, but when I close my server and restart it sometimes it gives me this console error “ReferenceError: BABYLON is not defined”

Ideas ?

Thanks

Anes

can you sahre your code or make sure you referenced babylon.js in your header?

this is the HTML Script from the template First Steps - Babylon.js Documentation.
when I start XAMP server to test. it works fine in all my browsers (mozila, chrome) (I use port 8080) but when I use another server integrated in an other software (because I need to open the page in a browser which is integrated in this software and it offers a client server generator), so I opened port 8080 in this software (after closing it from XAMP) and when I open the page nothing happens it open only in chrome !
this is why I don’t understand, normally even if I change the server it should work because the browser who interpreted the html file

thank you

 <script src="/babylonTest/babylon.js"></script>
 <canvas id="renderCanvas" touch-action="none"></canvas> //touch-action="none" for best results from PEP

<script>
    var canvas = document.getElementById("renderCanvas"); // Get the canvas element 
    var engine = new BABYLON.Engine(canvas, true);  // Generate the BABYLON 3D engine

    /******* Add the create scene function ******/
    var createScene = function () {

        // Create the scene space
        var scene = new BABYLON.Scene(engine);

        // Add a camera to the scene and attach it to the canvas
        var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, new BABYLON.Vector3(0,0,5), scene);
        camera.attachControl(canvas, true);

        // Add lights to the scene
        var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), scene);
        var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 1, -1), scene);

        // Add and manipulate meshes in the scene
        var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter:2}, scene);

        return scene;
    };
    /******* End of the create scene function ******/    

    var scene = createScene(); //Call the createScene function

    // Register a render loop to repeatedly render the scene
    engine.runRenderLoop(function () { 
            scene.render();
    });

    // Watch for browser/canvas resize events
    window.addEventListener("resize", function () { 
            engine.resize();
    });
</script>

Pinging @sebavan

Do you see any error message in the browser console ? and can you validate that the file is loading in the browser inspector ?

the error from console is ReferenceError: BABYLON is not defined
So like I said before when I use XAMP to start my apache server at port 8080, it works fine in all browsers.
but when I change the server and use another software to genarate the client server, it works only in chrome, in mozila the error ReferenceError: BABYLON is not defined

If it doesn’t work on any browsers I’ll said that the problem on my webclient server, but it works fine on chrome but not in mozila and the internal browser of the software.

thanks

So I would guess it is related to your server here and maybe it could be related to browser agent ?

You need to check with the dev tools to ensure the files are correctly doanloaded.

But the software I use it has a webClient server (to make my pc server so that I can use http://localhost…), like wamp, xamp … etc, the browser who interpreted the HTML file, how mozila when I used XAMP it whorks fine but when I change XAMP with my webClient server it doesn’t work (chrome work with the both)

and this problem is only when I use BJS, if I test with a simple HTML file it works fine

how to check with dev tools ?

thank you so match

I got this error also in my browser console (it’s before BABYLON is not defined )
“GET http://localhost:8080/babylonTest/babylon.js net::ERR_ABORTED 404 (Not Found)”