# specifier_escapes_root

> A relative import climbs above the package root.

A relative import climbs above the package root.

| | |
| --- | --- |
| Kind | Build or validation problem |
| Reported by | Archive and source validation |
| `disko` exit code | 1 (problems) |

A relative import uses more `../` segments than there are directories above the
importing file, so it points outside the project root. A package can only
import its own files.

## Why it happens

A common cause is sharing code between projects by importing it from a sibling
directory. Each game must contain every file it uses.

## Wrong

```text
games/
  shared/physics.js
  arena/
    game.json
    src/main.js      imports "../../shared/physics.js"
```

## Right

```text
games/
  arena/
    game.json
    src/main.js      imports "./physics.js"
    src/physics.js
```

Copy the shared file into the project and import it with a path inside the
project.

## See also

- [Project structure & imports](/games/project-structure)
- [`specifier_invalid`](/errors/specifier_invalid)
