SyntaxError: Cannot use import statement outside a module when running it in live server

//this is the greet.js file

import React from "react";

function Greet()
{
   return (
    <div><h1>Welcome</h1></div>
   )
}
export default Greet

//This is the indx.js file

import React,{Component} from 'react'
import Greet from './Greet'

class App extends Component
{
   render()
  {
     <div className='App'>
        <Greet/>
     </div>
   }
}

//This is the html file

<!DOCTYPE html>
 <html>
   <head>
     <title>
      Here We Go
     </title>
  </head>
   <body>
     <script src="indx.js"> </script>
   </body>
 </html>

I am trying to fetch the data from Greet.js and render it in indx.js but I am geeting error of cannot use import statement outside a module