I am learning React and I have written this code:
import React from "react";
import ReactDOM from "react-dom";
const element = <h1>Hello World!</h1>;
ReactDOM.render(element, document.getElementById('root');
However, on executing the Programme, I am getting this error:
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
As a can't understand what is the problem in the code. Please do help me out.