---
title: MARKLESS_ELEMENT_MODULE_SCOPE
description: "element() cannot be created at module scope: a Markless compiler error."
sidebar: { hidden: true }
search: { keywords: ["ELEMENT_MODULE_SCOPE","element module scope","markless error"] }
pagination: false
---

**Error** from the compiler, while it builds your `.tsrx` files.

## What happened

Markless prints the message, the reason, and a suggestion:

```text
MARKLESS_ELEMENT_MODULE_SCOPE: Cannot create element handle "<name>" at module scope.
Element handles are per-render DOM locators. A module-scope handle would be shared across requests and cannot point at one document-owned host element.
Move element() creation into the component that owns the host element and bind it with el={handle}.
https://markless.dev/errors/MARKLESS_ELEMENT_MODULE_SCOPE
```

Words in angle brackets change from case to case.

## How to fix it

Start with the suggestion in the message above.

This page has no guide yet. [Help write it](/contributing/improve-these-docs).

## Where it comes from

`@markless/compiler` raises this code. Source:

- [packages/compiler/src/passes/semantic-graph/diagnostics.ts](https://github.com/compiled-run/markless/blob/main/packages/compiler/src/passes/semantic-graph/diagnostics.ts)

Read [how to read a Markless error](/tooling/diagnostics), or go back to [all error codes](/errors).
