This error occurs when an "import" statement is used outside a JavaScript module. A module is a file containing JS code and it allows you to organize your code into separate files.
To fix this issue, make sure that your code is written as a module or that you are using a module bundler like Webpack to bundle your code before running it in the browser.
You can create a module in JavaScript by adding the "type=module" attribute to your script tag in your HTML file like this:
<script type="module" src="your-module.js"></script>
In your-module.js file, you can use "import" statements to import other modules.
If you are using a module bundler like Webpack, you can write your code without worrying about modules and the bundler will take care of creating modules and bundling your code.