errors and warnings / parsing / E0108
E0108 error
import / export not at the top level of a module
- area
- parsing (x01xx)
- fails the build
- yes
import or export is inside a block (a function, if, loop or do).
Both only work at the top level of a file: imports are resolved when the
file loads, and exports become the module's table. Move the import to the
top of the file, and export a top-level declaration.
Example
local function start() import after from "wowlua:timer" after(1, function() print("started") end)endstart()import after from "wowlua:timer" local function start() after(1, function() print("started") end)endstart()The compiler reports it like this:
error[E0108]: `import` is only allowed at the top level of a file ┌─ src/main.wowlua:2:5 │ 2 │ import after from "wowlua:timer" │ ^^^^^^ here
Related codes
| code | message |
|---|---|
| E1011 | Top-level import after another (non-import) statement |
| E0115 | class, enum, declare or overload function not at the top level of a file |
Offline
$ wowlua explain E0108 E0108 (error): import / export not at the top level of a module