# Load WASI module from local wasm file?

**URL:** <https://talk.observablehq.com/t/load-wasi-module-from-local-wasm-file/7596>\
**Category:** Help\
**Created:** [February 5, 2023, 1:18am UTC](https://talk.observablehq.com/t/load-wasi-module-from-local-wasm-file/7596 "2023-02-05T01:18:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdwfrost](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/sdwfrost/32/139_2.png) [@sdwfrost](https://talk.observablehq.com/u/sdwfrost)\
**Post date:** [February 5, 2023, 1:18am UTC](https://talk.observablehq.com/t/load-wasi-module-from-local-wasm-file/7596/1 "2023-02-05T01:18:35Z")

</div>

Hi everyone,

I’m trying to load a WASI module compiled with WASI-SDK from a local wasm file, using examples from [this repository](https://github.com/rob-blackbourn/example-wasm-array-passing). I can easily compile and load these examples without using stdlib, e.g. for ‘example1.c’:

```auto
addTwoInts = {
    const buf = await FileAttachment("./example1.wasm").arrayBuffer();
    // Create a WebAssembly instance from the wasm.
    const res = await WebAssembly.instantiate(buf, {});
    // Get the function to call.
    const { addTwoInts } = res.instance.exports;
    return(addTwoInts);
}

```

However, for more elaborate examples, I’d like to use libc. However, when I used modules compiled using WASI-SDK, I get the following error:

```auto
TypeError: WebAssembly.instantiate(): Import #0 module="env" error: module is not an object or function

```

Is there a WASI module loader that works in Observable with local wasm files?

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [February 5, 2023, 12:36pm UTC](https://talk.observablehq.com/t/load-wasi-module-from-local-wasm-file/7596/2 "2023-02-05T12:36:55Z")

</div>

Can you share an example notebook that has your compiled modules attached?

---

<div class="post-metadata">

**Author:** ![Igor-A1](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/igor-a1/32/5755_2.png) [@Igor-A1](https://talk.observablehq.com/u/Igor-A1)\
**Post date:** [February 5, 2023, 8:36pm UTC](https://talk.observablehq.com/t/load-wasi-module-from-local-wasm-file/7596/3 "2023-02-05T20:36:18Z")

</div>

try this with

```auto
addTwoInts = {
  const { WebAssembly } = window,
    buf = await FileAttachment("./example1.wasm").arrayBuffer(),
    module = new WebAssembly.Module(buf),
    instance = new WebAssembly.Instance(module, {});
  return instance.exports;
}

```
