# What's the best way to use babylon as modules but also stay in sync with the nightly builds / branches?

**URL:** https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492
**Category:** Questions
**Created:** [June 7, 2021, 9:44pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492 "2021-06-07T21:44:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![br-matt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/br-matt/32/22436_2.png) [@br-matt](https://forum.babylonjs.com/u/br-matt)
#### Post date: [June 7, 2021, 9:44pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492/1 "2021-06-07T21:44:59Z")

</div>

I get that there can not be new npm package versions every night.

How do some people go about using Babylon in their npm/webpack based project as a repo instead of from npm itself. Also how does that factor into your CI/CD process ?

Finding more than once that new bugfixes and features are available and it’s painful waiting for a new npm version to test them out.

---

<div class="post-metadata">

### Author: ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)
#### Post date: [June 7, 2021, 9:56pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492/2 "2021-06-07T21:56:48Z")

</div>

We are super flexible to build new release. Simply ask 🙂

---

<div class="post-metadata">

### Author: ![br-matt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/br-matt/32/22436_2.png) [@br-matt](https://forum.babylonjs.com/u/br-matt)
#### Post date: [June 7, 2021, 10:07pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492/3 "2021-06-07T22:07:21Z")

</div>

Oh, could use one then to test a recent bug fix. Thanks 🙂

I thought maybe some people out there were using local modules or something

---

<div class="post-metadata">

### Author: ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)
#### Post date: [June 7, 2021, 10:43pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492/4 "2021-06-07T22:43:50Z")

</div>

If you are using ES6 modules you can checkout the repository itself and follow the contribution guidelines to get that started. At that point you can run `gulp npmPackages-es6`. Going forwards you can run `git pull` to build the latest from source control. What it does is `npm link` the modules and then you can check them out in your project like `npm link @babylonjs/core`. That’s definitely a more complicated way to work against recent fixes, for example. Easiest way is to wait for NPM or request a nightly build 🙂

---

<div class="post-metadata">

### Author: ![br-matt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/br-matt/32/22436_2.png) [@br-matt](https://forum.babylonjs.com/u/br-matt)
#### Post date: [June 7, 2021, 10:44pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492/5 "2021-06-07T22:44:57Z")

</div>

Thanks, I might give that a try and see how jenkins likes it too 🤔

---

<div class="post-metadata">

### Author: ![br-matt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/br-matt/32/22436_2.png) [@br-matt](https://forum.babylonjs.com/u/br-matt)
#### Post date: [June 8, 2021, 2:59pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492/6 "2021-06-08T14:59:49Z")

</div>

I made a small script to automate what @brianzinn explained. I don’t recommend using it if you don’t understand what it’s doing or use it all the time. Can be nice to test preview though without having to bother @Deltakosh too much. Also makes it easier to start contributing, if you want to point it at your own fork instead.

```auto
const path = require('path');
const util = require('util');
const fs = require('fs-extra');
const exec = util.promisify(require('child_process').exec);
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

const currentDir = process.cwd()
const parentDir = path.dirname(currentDir)

if (fs.existsSync(`${parentDir}/Babylon.js`)) {
    rl.question("Do you want to pull and rebuild Babylon ? (y/n)", function(answer) {
        const answerCased = answer.toLowerCase()
        rl.close();
        if (answerCased === 'y') {
            exec(`cd .. && cd Babylon.js && git pull origin preview && npm install && cd Tools/Gulp && gulp npmPackages-es6`)
        } else {
            console.log("Babylon.js engine update skipped")
        }
      });
} else {
    rl.close();
    console.log("Cloning and building Babylon.js preview branch...")
    exec(`cd .. && git clone git@github.com:BabylonJS/Babylon.js.git --branch preview --depth 1 && cd Babylon.js && npm install && cd Tools/Gulp && gulp npmPackages-es6`)
} 

```

This gets added to package.json as

```auto
"preinstall": "buildBabylon.js"

```

and the modules become:

```auto
"@babylonjs/core": "../Babylon.js/dist",
"@babylonjs/inspector": "../Babylon.js/dist/inspector",
"@babylonjs/loaders": "../Babylon.js/dist/loaders",

```

This requires the prerequisite packages from the getting started contributing guide. Keep it mind it will make a Babylon.js folder one directory out from wherever your project is.

```auto
npm install -g typescript
npm install -g gulp@4.0.0

```

---

<div class="post-metadata">

### Author: ![kaliatech](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kaliatech/32/13557_2.png) [@kaliatech](https://forum.babylonjs.com/u/kaliatech)
#### Post date: [February 24, 2022, 4:02pm UTC](https://forum.babylonjs.com/t/whats-the-best-way-to-use-babylon-as-modules-but-also-stay-in-sync-with-the-nightly-builds-branches/21492/7 "2022-02-24T16:02:12Z")

</div>

The answer from brianzinn above is best if symlinks work for you. (i.e. `npm link`)

However, when running an IDE like Intellij IDEA on Windows, but building Babylon.js in WSL2, that won’t work well because [WSL2 doesn’t support symlinks from windows](https://github.com/microsoft/WSL/issues/5118). As a result, Intellij IDEA can’t see the symlinks in the /node\_modules folder.

(Intellij is working on solutions, but nothing great yet AFAIK. VS Code doesn’t have this problem if using [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl)).

So to do a quick build and check of nightly, an alternative is to pack the newly built modules and install them:

```bash

# Build packages (will also npm link them, but can be problematic with Windows/WSL2)
cd <babylon-path>/Tools/Gulp
git pull
gulp npmPackages-es6

# Change to your project and pack/install required modules
cd <your-project-dir>
npm install $(npm pack <babylon-path>/.temp/packageES6Dev/core | tail -1)
npm install $(npm pack <babylon-path>/.temp/packageES6Dev/gui | tail -1)

```

The package.json will contain entries like this:

```json
  "@babylonjs/core": "file:babylonjs-core-5.0.0-beta.11.tgz",
  "@babylonjs/gui": "file:babylonjs-gui-5.0.0-beta.11.tgz",

```
