JS: Module Specifer

By Xah Lee. Date: . Last updated: .

Module Specifer

module specifier is the path or URL for the module.

For example, when loading a a JS file from HTML

<script type="module" src="specifer"></script>

the value of attribute src is called module specifer

Module Specifer Restriction

Module Specifer must start with one of:

(Module Specifer cannot start with a file name e.g. my-module.js)

Example. Module Specifer Errors

2018-03-19 in safari, this is error:

<script type="module" src="main.js"></script>

you get:

TypeError: Module specifier does not start with "/", "./", or "../".

must be like this

<script type="module" src="./main.js"></script>

2018-03-19 in safari, this is error

<script src="./main.js"></script>

you get

SyntaxError: Unexpected token '{'. import call expects exactly one argument.

must be

<script type="module" src="./main.js"></script>

JavaScript. Module Import Export