Lizzy
Lizzy

Reputation: 137

how to resolve React error Module build failed (from ./node_modules/babel-loader/lib/index.js):

I am trying to learn React. I am trying to display the string Hello World but get the following error in my browser:

Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: C:\react\react-app\src\index.js: Missing semicolon. (1:6)

And I get these errors in my Editor: 1)'import ... =' can only be used in TypeScript files. 2)'=' expected. 3)';' expected.

My code is as follows:

import React from "react";
import ReactDom form "react-dom";

const element = <h1>Hello World</h1>;
ReactDom.render(element, document.getElementById('root'));

I would appreciate any help.

Upvotes: 2

Views: 570

Answers (2)

oykn
oykn

Reputation: 190

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

index.tsx

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);
root.render(
  <React.StrictMode>
    <react-app />
  </React.StrictMode>
);
reportWebVitals();

Upvotes: 0

Lizzy
Lizzy

Reputation: 137

See neeraj tk's comment = correct answer

I typed from instead of form. When I fixed this the code worked.

Upvotes: 1

Related Questions