0

I'm getting a strange error as

./src/index.js Line 56:15: Parsing error: '>' expected

I followed the official guide by create-react-app for Adding TypeScript to my existing Create React App project. And after changing just the two .js files(index and App) to .tsx, the project compilation is getting failed.

I uninstalled the global create-react-app by following this troubleshooting guide

index.tsx file

import React from "react";
import ReactDOM from "react-dom";
ReactDOM.render(
  <App store={store} persistor={persistor} basename={PUBLIC_URL} />,
  document.getElementById("root")
);

Note: I have changed my index.js file to index.tsx but still getting error for index.js. I guess it's throwing error after compilation to .js

2
  • Add your App.tsx and Index.tsx? Commented Aug 24, 2020 at 9:53
  • 1
    Please include the content of the relevant line (./src/index.js Line 56) Commented Aug 24, 2020 at 10:22

2 Answers 2

2

/src/index.js Line 56:15: Parsing error: '>' expected

You are using JSX in a .js file. Rename the file to .jsx (or even better `.tsx).

More

You can compare to a TypeScript app by npx create-react-app example --template typescript 🌹

Sign up to request clarification or add additional context in comments.

2 Comments

I already changed my index.js to index.tsx and App.js to App.tsx
If you are still getting an error in src/index.js even though the file no longer exists, just close and restart the process giving you the error.
0

After a useless struggle of 3 hours I found the root cause of error :)

As I mentioned earlier in the question I removed global create-react-app package to avoid problems but that created the problem. I don't know why but when, I reinstalled the create-react-app, the problem is resolved!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.