DEV Community

loading...

Discussion on: Building a 3D application with Electron and BabylonJS using TypeScript

Collapse
toohaan profile image
toohaan

Hi Justin,
such a nice tutorial, excatly what I was looking for.
It works perfectly with the same package versions you give. Unfortunatly I get issues when trying to use the latest version, aka
babylonjs@4.0.3
electron@6.0.12
typescript@3.6.4

"Uncaught ReferenceError: require is not defined at index.html:34"

I'm new to all those techs, so I can't figure out how to make it work and start with a clean base with up to date packages, do you have any clue?

Collapse
jodo profile image
Johannes Dobler

There was a breaking change in electron. the "nodeIntegration" flag is now default to false. You need to set it to true as it inserts "require" into the DOM. So add this to your BrowserWindow:

mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
}
});

Collapse
toohaan profile image
toohaan

thx Johannes,

it works like a charm.