Npm, bjs 4.0, inspector

Can I get 4.0 via npm?

Really I’m just looking for const BABYLON = require(‘babylonjs’) to work. I’m open to temporary solutions like shoving some new files into my current node modules, I’m just not sure about the structure.

Also how would one get the inspector working in such a scenario? Adding an html script link to the inspector bundle cannot reach BABYLON (b/c it isn’t bound to the window).

So here is a good read:

4.0 is already on npm:

1 Like

I run into an error when I start loading meshes:

ReferenceError: File is not defined
at Function.x._getFileInfo (mypath\node_modules\babylonjs\babylon.js:1:1199498)
at Function.x.ImportMesh (mypath\node_modules\babylonjs\babylon.js:1:1200424)
at Object.<anonymous> (mypath\babylon-4-nullengine-test.js:12:21)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:776:12)
at executeUserCode (internal/bootstrap/node.js:342:17)

With this code ( ). I’ve changed the first two lines from the example:,

var BABYLON = require("babylonjs");
var LOADERS = require("babylonjs-loaders");
global.XMLHttpRequest = require('xhr2').XMLHttpRequest;

var engine = new BABYLON.NullEngine();
var scene = new BABYLON.Scene(engine);

var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);

var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene);

BABYLON.SceneLoader.ImportMesh("", "", "skull.babylon", scene, function (newMeshes) { = newMeshes[0];

    console.log("Meshes loaded from babylon file: " + newMeshes.length);
    for (var index = 0; index < newMeshes.length; index++) {

    BABYLON.SceneLoader.ImportMesh("", "", "DamagedHelmet.gltf", scene, function (meshes) {
        console.log("Meshes loaded from gltf file: " + meshes.length);
        for (var index = 0; index < meshes.length; index++) {

    console.log("render started")
    engine.runRenderLoop(function() {

“dependencies”: {
“babylonjs”: “^4.0.0-alpha.14”,
“babylonjs-loaders”: “^4.0.0-alpha.14”,
“babylonjs-materials”: “^4.0.0-alpha.14”,
“xhr2”: “^0.1.4”

Oh but you are on a nullengine context?
This is probably related to File object then

Can you check if File object exists in your context?

I know how to fix it :slight_smile:
Stay tuned!

Ok fixed! Will be in next npm release (probably today)

1 Like

I just tried this out and can confirm that alpha 15 fixes the mesh loading for NullEngine as well as the ‘disappearing updatable meshes when cameras move’ from the other thread.

So awesome, ty!!

1 Like