'Cannot set property 'flatbuffers' of undefined'


so the engine complains about that error when i do

let builder = new flatbuffers.Builder(1024) 

any help appreciated.

Did you integrate flatbuffers yourself? And what language is flatbuffers implemented?

Yes i did install it with npm, both flattbuffers and @types and then imported flatbuffers in my file without any problems.
Flatbuffers module is javascript and @types is typescript.

Thanks for help.

Sorry, i do not the problem. I asked my colleague to take a look.

You could use it like this:

import { flatbuffers } from 'flatbuffers/js/flatbuffers.mjs';
console.log(new flatbuffers.Builder(1024));
1 Like

not working

Cannot find module 'flatbuffers/js/flatbuffers.mjs' or its corresponding type declarations.

This is type error. Does it work in at runtime?

You are right, its only a type error and actually does work at runtime.

Thank you!

Now i need to fix this warning in vscode somehow, super ugly :slight_smile:

edit: disabled type error in vscode with // @ts-expect-error

You may try to create a new .d.ts file with:

declare module "flatbuffers/js/flatbuffers.mjs" {
    export * from "flatbuffers";

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.