# FMOD not defined in HTML5

**URL:** <https://qa.fmod.com/t/fmod-not-defined-in-html5/19262>\
**Category:** FMOD Studio\
**Tags:** html5\
**Created:** [September 12, 2022, 12:14am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262 "2022-09-12T00:14:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahilmishra](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sahilmishra](https://qa.fmod.com/u/sahilmishra)\
**Post date:** [September 12, 2022, 12:14am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262/1 "2022-09-12T00:14:13Z")

</div>

Hi yall  
I feel dumb im just setting this up with a simple html5 site in typescript and when compiled it doesn’t like the global FMOD and says its not defined. Any ideas, also couldn’t find a code starter a link would be helpful.

---

<div class="post-metadata">

**Author:** ![sahilmishra](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sahilmishra](https://qa.fmod.com/u/sahilmishra)\
**Post date:** [September 12, 2022, 1:14am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262/2 "2022-09-12T01:14:16Z")

</div>

I’ve included the error, the html and the ts, the error occurs on line 26 in the type script

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/52f33075e434cd2c9cd5ae7765a4a65bac502e9f.png)

---

<div class="post-metadata">

**Author:** ![sahilmishra](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sahilmishra](https://qa.fmod.com/u/sahilmishra)\
**Post date:** [September 12, 2022, 1:15am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262/3 "2022-09-12T01:15:14Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/4a72c70c5637cdcee5f85c7951a6411db55cb4aa.png)

---

<div class="post-metadata">

**Author:** ![sahilmishra](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sahilmishra](https://qa.fmod.com/u/sahilmishra)\
**Post date:** [September 12, 2022, 1:16am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262/4 "2022-09-12T01:16:19Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/c6fb1538e2f0fe74ef95b2888fcac2190f467798.png)

---

<div class="post-metadata">

**Author:** ![tamachan87](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tamachan87/32/3691_2.png) [@tamachan87](https://qa.fmod.com/u/tamachan87)\
**Post date:** [September 12, 2022, 1:47am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262/5 "2022-09-12T01:47:18Z")

</div>

You need to instantiate the `FMOD` variable in your script. From the example JS files included in the download, you can see these at the top:

```nohighlight
//==============================================================================
// Prerequisite code needed to set up FMOD object. See documentation.
//==============================================================================

var FMOD = {}; // FMOD global object which must be declared to enable 'main' and 'preRun' and then call the constructor function.
FMOD['preRun'] = prerun; // Will be called before FMOD runs, but after the Emscripten runtime has initialized
FMOD['onRuntimeInitialized'] = main; // Called when the Emscripten runtime has initialized
FMOD['INITIAL_MEMORY'] = 64*1024*1024; // FMOD Heap defaults to 16mb which is enough for this demo, but set it differently here for demonstration (64mb)
FMODModule(FMOD); // Calling the constructor function with our object

```

---

<div class="post-metadata">

**Author:** ![sahilmishra](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sahilmishra](https://qa.fmod.com/u/sahilmishra)\
**Post date:** [September 12, 2022, 1:53am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262/6 "2022-09-12T01:53:42Z")

</div>

sure but the code generates that data into the variable fmod, im looking for the global enums

```auto
var fmod = {
    TOTAL_MEMORY: 24 * 1024 * 1024,
    preRun: preRun,
    onRuntimeInitialized: main
};

```

is the same thing as above from what i can tell of the compiled js.

if i just past that into the js I get this

```auto
Uncaught TypeError: FMOD.STUDIO_INITFLAGS is undefined

```

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [September 19, 2022, 12:35am UTC](https://qa.fmod.com/t/fmod-not-defined-in-html5/19262/7 "2022-09-19T00:35:56Z")

</div>

Hi,

What version of the API are you currently using and are you able to get any of the HTML5 examples to run? The examples are found in `fmodstudioapo(versionnumber)hmtl5->api->core->examples`. If you need help getting those up and running it can be found under[Platform Specific Details | HTML5](https://fmod.com/docs/2.02/api/platforms-html5.html#html5-specific-starter-guide).
