1

I have been trying to import this module which returns live stock prices. Each time I try to import it I get an error from google saying I cannot "use import statement outside of module."

Html Code:

<html lang="en">
<head>

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

</head>
<body>
    <p id="p">hello world</p>
    <button type="button" >Hello world</button>
</body>

</html>

Javascript code:

import { getCurrentPrice } from './modules/yahoo-stock-prices';

document.getElementById("p").innerHTML = getCurrentPrice("AAPL");

Google Error:

JSpractice.js:1 Uncaught SyntaxError: Cannot use import statement outside a module

Any advice?

Wilfred
  • 47
  • 5
  • possible solution [here](https://stackoverflow.com/questions/58211880/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-import) – alewis729 Jan 17 '21 at 04:07
  • @alewis729 I have tried those solutions already. :( – Wilfred Jan 17 '21 at 04:08

0 Answers0