# Trying to use ES Modules with Alloy

**URL:** <https://forum.repebble.com/t/trying-to-use-es-modules-with-alloy/455>\
**Category:** Watchapp/Face Developers Corner\
**Created:** [April 2, 2026, 5:34pm UTC](https://forum.repebble.com/t/trying-to-use-es-modules-with-alloy/455 "2026-04-02T17:34:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbhgl](https://avatars.discourse-cdn.com/v4/letter/p/77aa72/32.png) [@pbhgl](https://forum.repebble.com/u/pbhgl)\
**Post date:** [April 2, 2026, 5:34pm UTC](https://forum.repebble.com/t/trying-to-use-es-modules-with-alloy/455/1 "2026-04-02T17:34:21Z")

</div>

I created a new Alloy project and followed the example from [Getting Started with Alloy // Pebble Developers](https://developer.repebble.com/guides/alloy/getting-started/#using-es-modules)  
i.e. I added a new file `math.js` in the same folder as `main.js` with the content

```auto
export function add(a, b) {
    return a + b;
}

export function multiply(a, b) {
    return a * b;
}

```

and replaced the code in `main.js` with

```auto
import { add, multiply } from "./math";

console.log("Sum: " + add(2, 3)); // 5
console.log("Product: " + multiply(4, 5)); // 20

```

It compiled and installed successfully, but the log shows the following problem:

```auto
$ pebble logs --emulator emery
[19:31:24] xsHost.c:155> Found mod "pebble.moddable.tech"
[19:31:24] xsRun.c:408> Exception SyntaxError: import add not found

```

How can I make it work?

---

<div class="post-metadata">

**Author:** ![pizzaisdavid](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@pizzaisdavid](https://forum.repebble.com/u/pizzaisdavid)\
**Post date:** [April 2, 2026, 9:46pm UTC](https://forum.repebble.com/t/trying-to-use-es-modules-with-alloy/455/2 "2026-04-02T21:46:27Z")

</div>

I’m a bit lazy to check that it actually works, so I might be wrong.

But have you seen this example which imports from another file?

> <https://github.com/Moddable-OpenSource/pebble-examples/blob/main/hellomodule/src/embeddedjs/main.js>

---

<div class="post-metadata">

**Author:** ![pbhgl](https://avatars.discourse-cdn.com/v4/letter/p/77aa72/32.png) [@pbhgl](https://forum.repebble.com/u/pbhgl)\
**Post date:** [April 3, 2026, 2:10pm UTC](https://forum.repebble.com/t/trying-to-use-es-modules-with-alloy/455/3 "2026-04-03T14:10:25Z")

</div>

Thanks for the hint! I had seen this example before, but after looking at it again I finally found what was missing:

After modifying `src/embeddedjs/manifest.json` and replacing

```auto
	"modules": {
		"*": "./main.js"
	}

```

with

```auto
	"modules": {
		"*": [
			"./main",
			"./math.js"
		]
	}

```

it finally worked 🙂

Maybe this should be added to the documentation?
