# ImportMeshAsync error

**URL:** <https://forum.babylonjs.com/t/importmeshasync-error/46504>\
**Category:** Bugs\
**Created:** [December 17, 2023, 9:57am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504 "2023-12-17T09:57:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 17, 2023, 9:57am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/1 "2023-12-17T09:57:00Z")

</div>

I know this question has come up a lot, but none of the solutions I’ve seen are working for me.

I’m getting this error:

```auto
Uncaught (in promise) RuntimeError: Unable to load from ./assets/models/tree.glb: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse
    at errorHandler (index.js:49172:40)
    at Object.importMesh (index.js:122760:9)
    at index.js:49205:27
    at dataCallback (index.js:49048:7)
    at index.js:16809:5
    at XMLHttpRequest.onReadyStateChange (index.js:16905:17)

```

I’m trying to import a mesh like so:

```function
 SceneLoader.ImportMeshAsync(['tree'], './assets/models/', 'tree.glb', undefined, undefined, '.glb').then((result) => {
   const tree = result.meshes[0];
   tree.position = new Vector3(0, 0, 0);
 });
}

```

Here are my imports:

```auto
import { Engine, HemisphericLight, Scene, SceneLoader, UniversalCamera, Vector3 } from '@babylonjs/core';
import { Inspector } from '@babylonjs/inspector';
import { EcsEngine } from './ecsEngine';
import { Section, TrackComponent } from './components/track.component';
import { Entity } from 'tick-knock';
import { initSystems } from './startup/systemRegistration';
import { LocomotiveComponent } from './components/locomotive.component';
import '@babylonjs/loaders/glTF';

```

and my package.json:

```auto
{
  "name": "boxcar",
  "module": "index.ts",
  "type": "module",
  "devDependencies": {
    "bun-types": "^1.0.14"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@babylonjs/core": "^6.31.0",
    "@babylonjs/inspector": "^6.31.0",
    "@babylonjs/loaders": "^6.31.0",
    "eslint": "^8.54.0",
    "prettier": "^3.1.0",
    "tick-knock": "^4.2.0"
  }
}

```

You can find the whole repo here: [GitHub - ThomasBurgess2000/boxcar at choo-choo](https://github.com/ThomasBurgess2000/boxcar/tree/choo-choo) (relevant file is src/game.ts)

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [December 17, 2023, 11:44am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/2 "2023-12-17T11:44:01Z")

</div>

Check your GLB, it throws errors in any GLTF viewer.  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/4/94531c46b60f044a22186bb2ac536809b88b299e.png)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/d/4d65ae2de8fd6e5ec3d0ac45d9ae4bd44eb62231.png)

---

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 17, 2023, 11:55am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/3 "2023-12-17T11:55:11Z")

</div>

Bizarre, it works for me in the sandbox and the 3d viewer on Windows. Also the magic number error is a different type of error I believe, one that only happens after it has correctly tried to load it as glb. The JSON parse error makes me think it didn’t get that far.

 ![Screenshot_20231217-055246](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/9/f9f1892fd2dea3fd82864eee1d9f62f421e8eced.jpeg)

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [December 17, 2023, 11:57am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/4 "2023-12-17T11:57:51Z")

</div>

Do you use the same file that in GH repo?

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [December 17, 2023, 1:01pm UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/5 "2023-12-17T13:01:38Z")

</div>

The version on GH is saying ‘trying to load tree’? Might not be fully uploaded or something else wrong with your branching.

---

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 17, 2023, 8:58pm UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/6 "2023-12-17T20:58:33Z")

</div>

Yes, when I posted that screenshot I downloaded it on my phone from the branch I linked (“choo-choo”) where the latest commit is “trying to load tree”.

I just downloaded it again on my laptop here:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/6/e6d12fea44020f44802eb09d2b1442e51119baa8.png)

and it worked again in the sandbox.

But just to show that it’s not the GLB, I just pushed another asset that I’ve used in a different project and definitely works (it’s just the default blender sphere).

However, this project still returns the same error.

---

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 17, 2023, 11:51pm UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/7 "2023-12-17T23:51:13Z")

</div>

I’m using bun for the first time in case that’s relevant

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [December 18, 2023, 1:02am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/8 "2023-12-18T01:02:06Z")

</div>

> [@thomas](#):
>
> I’m using bun for the first time in case that’s relevant

Check if absolute URLs work.

---

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 18, 2023, 2:34am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/9 "2023-12-18T02:34:12Z")

</div>

It does not. For reference, previous answers to this question centered around something wrong with the loader import:

> [@importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse](https://forum.babylonjs.com/t/importmesh-of-undefined-from-undefined-version-undefined-exporter-version-undefinedimportmesh-has-failed-json-parse/35264):
>
> Sorry for posting this as I have already seen a few others that are very similar. But I just can’t figure it out. I am unable to load models whatsoever after several days of trying. For example, I found this playground link here in the forum: But when I try to run it locally, I get the importMesh error. The only thing that I am doing differently is using the module imports (and webpack to build). I am able to get the demo app with the cylinder working using module imports and webpack, but…

> It looks like maybe you’re missing the GLTF loader. After you install the package “@babylonjs/loaders” then you can import GLTF loading support like below.
> 
> ```auto
> import "@babylonjs/loaders/glTF";
> 
> ```

> [@This error : undefined, exporter version: undfinedimportMesh has failed JSON PARSE](https://forum.babylonjs.com/t/this-error-undefined-exporter-version-undfinedimportmesh-has-failed-json-parse/27305):
>
> import { Scene, Engine, ArcRotateCamera, Vector3, Color3, SceneLoader, BoundingInfo } from 'babylonjs'; import 'babylonjs-loaders'; BABYLON.SceneLoader.ImportMesh( '', url, '', scene, (meshs, particleSystems, skeletons) =\> { meshes = meshs; and i load my file like this, it used to work but now its broken not sure why. im using npm and its a nextjs project. any ideas would be appreciated. I’m trying to load a glb model im on ba…

> Turns out it was a version mismatch with the babylonjs preview npm packages and 4.2.1
> 
> removing the preview package dependencies and updating the versions worked

However, as far as I can tell, I do not have a version mismatch and am importing the correct plugin.

---

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 18, 2023, 2:58am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/10 "2023-12-18T02:58:45Z")

</div>

This returns false:

```auto
  const isPluginAvailable = SceneLoader.IsPluginForExtensionAvailable('.glb');

```

And I also noticed I was missing this warning:

```auto
index.js:6908 BJS - [21:04:36]: Unable to find a plugin to load .glb files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes

```

I also confirmed that there are references to @babylonjs/loaders/glTF in my build/index.js file, so it seems like it’s not being tree-shaken or something.

---

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 18, 2023, 3:52am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/11 "2023-12-18T03:52:19Z")

</div>

what is SceneLoader2?

I can see that the gltf/glb extensions are being added here in the debugger:

```auto
if (SceneLoader2) {
  SceneLoader2.RegisterPlugin(new GLTFFileLoader);
}

```

While .babylon is being added in the separate SceneLoader

```auto
SceneLoader.RegisterPlugin({
  name: "babylon.js",
  extensions: ".babylon",

```

Here are those imports in the build file:

```auto
// node_modules/@babylonjs/loaders/node_modules/@babylonjs/core/Loading/sceneLoader.js
var SceneLoaderAnimationGroupLoadingMode2;
(function(SceneLoaderAnimationGroupLoadingMode3) {
  SceneLoaderAnimationGroupLoadingMode3[SceneLoaderAnimationGroupLoadingMode3["Clean"] = 0] = "Clean";
  SceneLoaderAnimationGroupLoadingMode3[SceneLoaderAnimationGroupLoadingMode3["Stop"] = 1] = "Stop";
  SceneLoaderAnimationGroupLoadingMode3[SceneLoaderAnimationGroupLoadingMode3["Sync"] = 2] = "Sync";
  SceneLoaderAnimationGroupLoadingMode3[SceneLoaderAnimationGroupLoadingMode3["NoSync"] = 3] = "NoSync";
})(SceneLoaderAnimationGroupLoadingMode2 || (SceneLoaderAnimationGroupLoadingMode2 = {}));

class SceneLoader2 {

```

```auto
// node_modules/@babylonjs/core/Loading/sceneLoader.js
var SceneLoaderAnimationGroupLoadingMode;
(function(SceneLoaderAnimationGroupLoadingMode2) {
  SceneLoaderAnimationGroupLoadingMode2[SceneLoaderAnimationGroupLoadingMode2["Clean"] = 0] = "Clean";
  SceneLoaderAnimationGroupLoadingMode2[SceneLoaderAnimationGroupLoadingMode2["Stop"] = 1] = "Stop";
  SceneLoaderAnimationGroupLoadingMode2[SceneLoaderAnimationGroupLoadingMode2["Sync"] = 2] = "Sync";
  SceneLoaderAnimationGroupLoadingMode2[SceneLoaderAnimationGroupLoadingMode2["NoSync"] = 3] = "NoSync";
})(SceneLoaderAnimationGroupLoadingMode || (SceneLoaderAnimationGroupLoadingMode = {}));

class SceneLoader {

```

---

<div class="post-metadata">

**Author:** ![thomas](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomas/32/29205_2.png) [@thomas](https://forum.babylonjs.com/u/thomas)\
**Post date:** [December 18, 2023, 6:11am UTC](https://forum.babylonjs.com/t/importmeshasync-error/46504/12 "2023-12-18T06:11:00Z")

</div>

it appears my modules got screwed up, deleting the bun lock and node\_modules resolved the issue
