Building BabylonJS on linux - Ubuntu 18.04.3 LTS

Hi, following a thread on hidden line removal with Deltakosh…

… I started out downloading everything so that I can start to experiment editing and building BabylonJS locally.

I followed the instructions on…

and encountered some problems - some I resolved others not yet. I thought it best to document the steps taken so far as well as the unresolved - offered as a questions but also as an offering for consideration in documentation.

  1. Unfortunately I did not take notes on this point but basically I had to run quite a few of the CLI commands on “how to start” using sudo they required super user permission. I should have noted down which commands but unfortunately I did not. Linux users might benefit from being advised - “try sudo in the event of failure”.

  2. I then came across a problem

============ log start ============================

1 verbose cli [ ‘/snap/node/2647/bin/node’, ‘/usr/local/bin/npm’, ‘run’, ‘build’ ]
2 info using npm@6.14.4
3 info using node@v14.0.0
4 verbose run-script [ ‘prebuild’, ‘build’, ‘postbuild’ ]
5 info lifecycle babylonjs@0.0.0~prebuild: babylonjs@0.0.0
6 info lifecycle babylonjs@0.0.0~build: babylonjs@0.0.0
7 warn lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/2647/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.
8 verbose lifecycle babylonjs@0.0.0~build: unsafe-perm in lifecycle true
9 verbose lifecycle babylonjs@0.0.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/jon/Babylon.js/Tools/Gulp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
10 verbose lifecycle babylonjs@0.0.0~build: CWD: /home/jon/Babylon.js/Tools/Gulp
11 silly lifecycle babylonjs@0.0.0~build: Args: [ ‘-c’, ‘gulp --max-old-space-size=8192 --tsLintFix’ ]
12 silly lifecycle babylonjs@0.0.0~build: Returned: code: 1 signal: null
13 info lifecycle babylonjs@0.0.0~build: Failed to exec build script
14 verbose stack Error: babylonjs@0.0.0 build: gulp --max-old-space-size=8192 --tsLintFix
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
14 verbose stack at EventEmitter.emit (events.js:315:20)
14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
14 verbose stack at ChildProcess.emit (events.js:315:20)
14 verbose stack at maybeClose (internal/child_process.js:1051:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
15 verbose pkgid babylonjs@0.0.0
16 verbose cwd /home/jon/Babylon.js/Tools/Gulp
17 verbose Linux 4.15.0-96-generic
18 verbose argv “/snap/node/2647/bin/node” “/usr/local/bin/npm” “run” “build”
19 verbose node v14.0.0
20 verbose npm v6.14.4
21 error code ELIFECYCLE
22 error errno 1
23 error babylonjs@0.0.0 build: gulp --max-old-space-size=8192 --tsLintFix
23 error Exit status 1
24 error Failed at the babylonjs@0.0.0 build script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

==================== log end ===============================

Being new to git / npm and node I fished around.

One measure taken was to stop my Apache2 local server which is what I run BabylonJS on.

The second measure which seemed to be the “fix” centered around item 7 in the above log ( I am not sure if the stop apache2 step was a factor ).

Advice on was followed namely I entered

npm config set scripts-prepend-node-path true

at the CLI.

  1. As far as I can make out I have built successfully but now fail to run tests due to headless browser (Chrome) associated errrors.

===== log start ======================

[16:31:10] Finished ‘buildes6’ after 40 s
[16:31:10] Starting ‘copyDist’…
[16:31:10] Finished ‘copyDist’ after 30 ms
[16:31:10] Finished ‘nodeEditor-es6’ after 41 s
[16:31:10] Finished ‘typescript-es6’ after 3.38 min
[16:31:10] Starting ‘netlify-cleanup’…
[16:31:10] Finished ‘netlify-cleanup’ after 391 μs
[16:31:10] Finished ‘typescript-all’ after 7.68 min
[16:31:10] Starting ‘documentation’…
[16:31:11] Finished ‘documentation’ after 107 ms
[16:31:11] Starting ‘typedoc-all’…
[16:31:11] Starting ‘typedoc-generate’…
[16:31:33] Finished ‘typedoc-generate’ after 23 s
[16:31:33] Starting ‘typedoc-validate’…
[16:31:34] All formatting check passed successfully during the validation !
[16:31:34] Finished ‘typedoc-validate’ after 799 ms
[16:31:34] Starting ‘typedoc-generateValidationBaseline’…
[16:31:35] All formatting check passed successfully during the baseline generation !
[16:31:35] Finished ‘typedoc-generateValidationBaseline’ after 773 ms
[16:31:35] Finished ‘typedoc-all’ after 24 s
[16:31:35] Starting ‘tests-all’…
[16:31:35] Starting ‘tests-unit’…
[16:31:35] Starting ‘tests-babylon-unit’…
[16:31:35] Starting ‘tests-unit-transpile’…
[16:31:40] Finished ‘tests-unit-transpile’ after 5.48 s
[16:31:40] Starting ‘’…
28 04 2020 16:31:41.149:WARN [config]: urlRoot normalized to “/karma/”
28 04 2020 16:31:41.564:WARN [filelist]: Pattern “/home/jon/Babylon.js/!./**/*.d.ts” does not match any file.
28 04 2020 16:31:57.807:INFO [karma-server]: Karma v4.4.1 server started at
28 04 2020 16:31:57.810:INFO [launcher]: Launching browsers ChromeHeadless with concurrency 1
28 04 2020 16:31:57.832:INFO [launcher]: Starting browser ChromeHeadless
28 04 2020 16:31:59.558:ERROR [launcher]: Cannot start ChromeHeadless
[0428/] Running as root without --no-sandbox is not supported. See

28 04 2020 16:31:59.559:ERROR [launcher]: ChromeHeadless stdout:
28 04 2020 16:31:59.559:ERROR [launcher]: ChromeHeadless stderr: [0428/] Running as root without --no-sandbox is not supported. See

28 04 2020 16:31:59.562:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
28 04 2020 16:31:59.702:ERROR [launcher]: Cannot start ChromeHeadless
[0428/] Running as root without --no-sandbox is not supported. See

28 04 2020 16:31:59.703:ERROR [launcher]: ChromeHeadless stdout:
28 04 2020 16:31:59.703:ERROR [launcher]: ChromeHeadless stderr: [0428/] Running as root without --no-sandbox is not supported. See

28 04 2020 16:31:59.704:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
28 04 2020 16:31:59.825:ERROR [launcher]: Cannot start ChromeHeadless
[0428/] Running as root without --no-sandbox is not supported. See

28 04 2020 16:31:59.826:ERROR [launcher]: ChromeHeadless stdout:
28 04 2020 16:31:59.826:ERROR [launcher]: ChromeHeadless stderr: [0428/] Running as root without --no-sandbox is not supported. See

28 04 2020 16:31:59.827:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.
[16:31:59] ‘’ errored after 19 s
[16:31:59] Error: 1
at formatError (/usr/local/lib/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/format-error.js:21:10)
at Gulp. (/usr/local/lib/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/log/events.js:33:15)
at Gulp.emit (events.js:327:22)
at Gulp.EventEmitter.emit (domain.js:485:12)
at Object.error (/home/jon/Babylon.js/node_modules/undertaker/lib/helpers/createExtensions.js:61:10)
at handler (/home/jon/Babylon.js/node_modules/now-and-later/lib/mapSeries.js:47:14)
at f (/home/jon/Babylon.js/node_modules/once/once.js:25:25)
at f (/home/jon/Babylon.js/node_modules/once/once.js:25:25)
at tryCatch (/home/jon/Babylon.js/node_modules/async-done/index.js:24:15)
at done (/home/jon/Babylon.js/node_modules/async-done/index.js:40:12)
at removeAllListeners (/home/jon/Babylon.js/node_modules/karma/lib/server.js:370:9)
at /home/jon/Babylon.js/node_modules/karma/lib/server.js:381:13
at Server.close (net.js:1603:9)
at Object.onceWrapper (events.js:421:28)
at Server.emit (events.js:327:22)
at Server.EventEmitter.emit (domain.js:547:15)
[16:31:59] ‘tests-babylon-unit’ errored after 25 s
[16:31:59] ‘tests-unit’ errored after 25 s
[16:31:59] ‘tests-all’ errored after 25 s
[16:31:59] ‘default’ errored after 9.18 min
npm ERR! errno 1
npm ERR! babylonjs@0.0.0 build: gulp --max-old-space-size=8192 --tsLintFix
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the babylonjs@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jon/.npm/_logs/2020-04-28T15_31_59_971Z-debug.log

============ log end ==================

I will continue to poke away, grateful for any advice.

Also interested to gain a perspective on this - is it likely that the build was successful but I simply cannot run the tests due to headless browser issues.

I am also interested to know if the CLI command

npm run build

Are there any options to avoid repeating build steps already successfully completed?
During my ignorant handling of these errors repeated build attempts have take a long time to get to the point of failure ( or a new point of failure ). I wondered if there were any options that could take account of successfully completed build steps and avoid some repetition ( kind of full build or partial build options ?).


I don’t believe any of us tried building with Node 14. And I would guess this is the problem (and not the operating system).
Have you tried a different node version?

Hi RaananW - thanks for the tip I will try that avenue.
I tried first with 12.16.3 which is the recommended offering for linux on

but that install failed for me - loads of errors I did not understand :slight_smile: so then I tried using the Ubuntu snap store and that worked.

Sounds like its time for me to take a longer look at why my first attempt at installing 12.16.3 failed.

Thanks for the tip - probably at my most confused right now since I am unfamiliar with pretty much all of the stuff I downloaded today, I am sure it will all make more sense over the coming days.

thanks Jon


14 is really new (I didn’t even know it was released), and with every node version we need to make minor adjustments to the build process, mainly due to deprecation of old APIs.
I believe 12 is a safer bet, will be interesting to know why it fails there.

And just so you know, none of us really knows any of those tools, we are just throwing numbers in the air and hoping to be right.

Ohh its not just me then :see_no_evil: right now I am a man wearing a blind fold in a dark room during a total eclipse :yum:

1 Like

Hope this can help a bit. On Ubuntu 18.04, I usually run:

sudo apt-get update
sudo apt upgrade
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs
ssh-keygen -t rsa -b 4096 -C <Github e-mail>
cat /home/ubuntu/.ssh/

Then I copy the output from cat and include it as a ssh key in my Github settings. Then I clone a Github repo with npm dependencies (has package.json and package-lock.json). Then, I run npm i in a folder with npm dependencies to generate the node_modules/ folder. Then I can run sudo node <name of .js script> to run a node script.

1 Like

Thanks gbz,

I went down that path from

But then my attempts at building BabylonJS were failing because of previous attempts at installing nodeJS - I got errors telling me that bindings for the required version of node-sass but it had found bindings for a previous installation ( different version ).

I thought I had captured these errors properly but it turns out I did not. I followed a lot of advice on forum threads by people reporting the same problem but nothing recommended worked.

In the end I decided to completely remove nodeJS and re-install the same way as you mentioned above. I followed instructions at…

However now when I try and install as above only nodejs gets installed npm does not.

nodejs -v
npm -v
bash: /usr/local/bin/npm: No such file or directory

/usr/local/bin/npm was one of the directories I cleaned out as part of the uninstall proceedings.

So now I guess I need to try again to totally remove nodejs and npm and start again.

I have been installing and uninstalling nodejs several times, always npm appeared to be missing, I typed

nodejs -v and got v12.16.2

but then

npm -v

bash: /usr/local/bin/npm: No such file or directory

Then I hunted around and found the npm executable under /usr/bin/npm and I think that is where it is supposed to reside so it looks as if some kind of link has not been set up correctly.

I tried to build babylonJS simply typing /usr/bin/npm instead of npm and now I am back to what seems like the earlier problem of issues with node-sass.

Module build failed (from /home/jon/Babylon.js/node_modules/sass-loader/dist/cjs.js):
Error: Cannot find module ‘node-sass’

So it looks as if I have 2 issues to resolve.

  1. npm at the moment I have to type in the full path to the executable.
  2. node-sass - the build cannot find the module.

Our automated build are actually all running on UBUNTU with node 12.16.1:

I am really wondering what the issue could be for you. Could you check your node-saas installation log as this has a native dependency I wonder if it might be the issue.

Hi Sebavan,

I managed to manually install node-sass.
I was then faced with the original problem which was failure to run chrome-headless during tests.
The error given there was

Cannot start ChromeHeadless
Running as root without --no-sandbox is not supported. See

The whole reason I was running as root (sudo) was permissions on src files indeed a lot of the installation process also had to be done using sudo.

Anyway I decided to tackle this another way and looked at permissions of files under my local Babylon.JS and there I saw inconsistencies.

For instance Babylon.js/src/Shaders/anaglyph.fragment.ts had permissions only for root. Files in other directories under src had permissions for me.

So it seemed that rather than try and build as super-user which resulted in the earlier failure it would have made more sense if I had tackled the whole thing as a permissions issue and changed directory permission, I suspect some of my problems started when I used sudo as a way of dealing with permission issues - certainly during the build and possibly during the installation.

So I changed all files under BabylonJS temporarily to have rw permissions for all ( uog ).

I was then able to build without being super user ( sudo ) and I got past the headless chrome tests with success.

Then I hit the next problem - the build then tried to run the tests on firefox and could not start firefox - so I passed everything on Chrome - I have firefox installed but the build process did not seem to be able to start it.

I am wondering at this stage some very basic things like.

  1. Does the build always take so long? I am proposing to make experimental (local - no release) changes to one file at the moment - I am a beginner, does the build always build everything?

  2. Is it possible to bypass the tests? Sure I understand why this is needed before putting any code out for consideration in the main project but can testing be turned off during early experimental development? It seems I can run Chrome testing but not firefox at the moment but really I would prefer not to test at all until I have had a chance to test out my ideas and see if they work at all - I have a proposal for hidden line removal and I am not sure how well it will work and if it does work then if the result will look decent and whether the project is worth pursuing.

I solved it by a manual install but it seemed to be down to directory permissions.

I would say do not worry with local full build and only use npm run start :slight_smile: it is slow to load first but really fast to iterate after.

Then once changes are ready make a PR and let the build server take the time hit.

You ll be able to see all the results online to do any changes if required.

I think I only build locally when I publish a new version :slight_smile:

Hi Sebavan, that sounds like the information I needed - thanks :smiley:

I wonder if any decision makers reading this might consider a “soft start” guide to getting development up and running? I am new to git, nodejs and npm so it has been a slow process.

I am also puzzled about the file permissions on the src files and so on which I think is down to git - as far as I know I only altered one file, I have been up and down many paths of investigation so its hard to say 100% sure that git delivered the files with mixed permissions but it does seem that way.

I think most of the problems experienced have been down to permissions or my first method of dealing with those issues which was to go into sudo mode.

Start Contributing to Babylon.js - Babylon.js Documentation this might be what you look for.

Thanks Sebavan

Possibly a bit softer than that :blush: I had already read that one but it assumes quite a lot of experience inmho.

For instance I have written a very large project ontop of Babylon - initially I imagined I would run a build of Babylon and then copy the main dist/babylon.js produced by my build into my project directory (after copying the existing babylon.js somewhere for safe keeping).

I need to bring the build to the project rather than take the project to the build because my project is very large ( a couple of months full time coding now ).

I took the precaution of not using my project directory for the git installed version of Babylon - I assume I would be able to copy across compiled JS files after saving the originals and play around.

The level of doc I would like to see would be to assume someone has written a project ontop of BabylonJS and wishes to swap in an alternative version of babylon.js to test out some changes - whats involved in testing “BabylonJS alt” - how to make a custom version of Babylon and run it in your existing project explaining how to avoid tests and long build times for the sake of simply getting something up and running quickly and painlessly.

Different people have different types of knowledge and experience - I found it very easy to dive straight into coding ontop of Babylon, I spent 15 years writing CADCAM code in C++ so 3D and transforms are second nature but I found it ten times more difficult to get started with making a few line changes inside Babylon - starting at this point I am not even sure what the result of a build is - can I naively expect to find a new dist/babylon.js and simply transfer that to where it is needed and expect to see my code changes reflected?

For instance I am wondering what the result of the “npm run start” will be - it is advising me that it has picked up my tweaking of the file I am interested in but the timestamp on my dist/babylon.js is still set at yesterday so I am not sure if I have to wait longer to see a change or if I have totally mis-understood what “npm run start” will produce and how I get from there to seeing a change at run time in my project folder.

Thanks for your help, I am very grateful, the above is not a moan by the way :grinning: I am grateful for all the help people have been giving me, just trying to explain why the doc provided is not transparent to me.

Adding @PirateJC for the doc :slight_smile:

I was thinking you wanted to contribute cause basically npm start runs everything locally without generating a release. The output is hidden in the .temp of the folder structure but is not meant to be consumable outside the dev env.

In your case you are right you would need to build and get your files from the dist folder.

If you only use babylon.js and not materials and so on, you can use gulp core to only build the core bundle without tests and so on :slight_smile: It will be available in the dist/preview release

I would nevertheless not recommend creating custom version cause most of what you need should be usable from outside, and if smthg is missing we should provide it :slight_smile: or create a PR for it.

The main idea is to be flexible enough to allow customization without requiring a local build :slight_smile:

Thanks Sebavan, is starting to make more sense to me now.

“I was thinking you wanted to contribute” Yes I do. I do would like to contribute the hidden line removal idea if successful to Babylon - by custom version I meant a temporary thing not a private fork - I am happy to share :slightly_smiling_face:

There are aspects of hidden line removal on meshes that may be scale dependent - by that I mean number and density of meshes (by density I mean how finely detailed) so I want to test against my project and not say a test cube or simple part.

Whilst I am playing around though I need to work in my project folder so it sounds as if I need to run the build process (and not npm start ) - it would be good to know if it is possible to disable the tests, to recap I am passing Chrome headless but the build process fails to open Firefox although I do have it installed.

But yes I do hope that the final code might be acceptable for inclusion into Babylon I do not think many people want hidden line removal but it has been requested at least once before. Its perhaps a bit retro with the sophistication of shaders to go back to line drawings with hidden line removal but I for one really want to see what it looks like when parts are animated - I think it might be quite cool.

yup so gulp core should do the trick :slight_smile:

@jonnie45 As this solidifies, I’d be happy to help get doc additions in to support it! Keep me posted.


Alert() finally popped up and said my name - which means my changes are running in my local project folder.

Thanks so much Sebavan - now I can replace alert() with something a little more useful.