# Fix the 'Unexpected identifier' error importing JS modules

> Learn how to fix the Unexpected identifier error when using ES module import in the browser, by adding type='module' to your script tag so imports work.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2019-01-31 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/how-to-solve-unexpected-identifier-modules/

If you are using the `import` statement to import different files in your [JavaScript](https://flaviocopes.com/javascript/) application, you might find the browser giving you this error: *Unexpected Identifier*.

![Unexpected identifier](https://flaviocopes.com/images/how-to-solve-unexpected-identifier-modules/Screen_Shot_2019-01-15_at_16.30.56.png)

Why? And how can you make ES6 modules work in browsers?

You just have to do one tiny change: instead of loading your main entry point JavaScript file using

```html
<script src="index.js"></script>
```

add `type="module"`:

```html
<script type="module" src="index.js"></script>
```

and things should now work fine.
