Methods missing from npm package?

It works on playground, and if i take the asyncfuntion2 off it also works on npx webpack serve, thats why i think the node_module for @babylonjs/gui is missing those methods that are on the preview CDN

Switch to BJS version 5 and your problem will be solved. It seems 4.2.1 really doesn’t have these methods. I did what I should do as the first. Created a project using 4.2.1 and it has only a Parse method and no getControlByName.

Or you can load the gui by fetching it from the server, pass it to the Parse method.

The getControlByName can be replaced by gui.getChildren().find(c => c.name === "name")

Sorry for being lame :stuck_out_tongue:

1 Like

Sample code for fetching:

const res = await fetch("url")
const json = await res.json()

I really wish we could start annotating more with @since. this has caught me so many times - even viewing source - My future self will try to remember we have a branch:
Babylon.js/advancedDynamicTexture.ts at 4.2.1 · BabylonJS/Babylon.js (github.com)

vs.

Babylon.js/advancedDynamicTexture.ts at master · BabylonJS/Babylon.js (github.com)

1 Like

Is there a way to get 5.0 through npm(the github page only shows up to 4.2)? I have no idea how to add modules to my project any other way, especially using typescript.

they are listed here:
@babylonjs/core - npm (npmjs.com)

5.0 is tagged with preview, so you can add that way with npm.

@DanilloCF shouldn’t this be marked as the solution dude?

This was already discussed somewhere on the forum and yes it could make our lives much more easier.

Just change 4.2.1 to ^5.0.0-beta in package.json and you’ll always have the latest beta release

  "dependencies": {
    "@babylonjs/core": "^5.0.0-beta",
    "@babylonjs/gui": "^5.0.0-beta",
    "@babylonjs/inspector": "^5.0.0-beta",
    "@babylonjs/loaders": "^5.0.0-beta",
    "@babylonjs/materials": "^5.0.0-beta",
    "@babylonjs/post-processes": "^5.0.0-beta",
    "@babylonjs/procedural-textures": "^5.0.0-beta",
    "@babylonjs/serializers": "^5.0.0-beta"
  }
2 Likes