-1
import React from 'react';
import ReactDOM from 'react-dom';
import './Navigation';

ReactDOM.render(
  <React.StrictMode>
    <Navigation/>
  </React.StrictMode>,
  document.getElementById('root')
);

showing syntax error Cannot use import statement outside a module"

lord
  • 43
  • 4
  • This thread might have solution https://stackoverflow.com/questions/58211880/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-import – Lucas Raza Jan 01 '22 at 18:38
  • Just fyi, stack trace should be the first thing to share, helps in tracking the exact place from which the error comes – akds Jan 01 '22 at 20:42

2 Answers2

0

change import './Navigation'; to import Navigation from './Navigation';

if Navigation is not default export then change it to import { Navigation } from './Navigation';

sandeep.kgp
  • 847
  • 2
  • 10
0

If you are loading this file from your HTML you will need to set the type to module on the script tag.

Like: <script type="module" src="/path/to/file.js"></script">

Jonathon Hibbard
  • 1,547
  • 13
  • 20