Importing and Implementing Havok in Vite\ React + Ts Project Fails

Hi everyone! I’m trying to import Havok into my project, but sadly I’m getting the following errors:

I’ve been looking at different forum posts here, but I can’t find a fix for this problem. I tried to replicate the implementation exposed here. This is how it looks:


Am I missing something here? Thanks!

Could you share the repository?
It would be easier to check the project itself

Sure, take a look: GitHub - ElHurta/hacking-automata

Babylon expects to find HavokPhysics.wasm in the same folder as HavokPhysics.js.

Vite will correctly copy it when building, but not while in dev mode.

You can see what Vite is building and serving in dev mode under ../node_modules/.vite/deps/.

You can configure Vite to serve Havok from its original location.

You might need to adjust the allowed path based on your configuration.

Add this to your vite.config.ts:

 server: {
        fs: {
          // Allow serving files outside of the root
          allow: [
optimizeDeps: { exclude: ["@babylonjs/havok"] },
1 Like

It works. Thanks a lot. For the record, I made some changes to my CreateNewScene method and It’s working perfectly. Now I need to learn the rest.