17

I'm new to react and i started an app using create react app.When i try to rename index.js to index.jsx, I'm getting an error saying "Module build failed: Error: ENOENT: no such file or directory, open '/home/qbuser/Desktop/onChat-final/new/chat/client/src/index.js'". What should be done? Where did I go wrong?

3 Answers 3

47

It's a bug with create-react-app dev server: it can't handle renaming of index.js to index.jsx and vice versa. Just restart your dev server

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

1 Comment

This is the correct answer. Just stop the dev server and start it again. It picks up index.jsx then.
9

You need to restart the app after renaming. I fail to find a reason for this but the solution works.

  1. Stop your app by pressing Ctrl + C.
  2. Then restart the app with npm start.

Comments

-10

Rename it back to index.js. The file can still contain JSX.

Or run "eject"/ use WebPack, then you can customize anything.

6 Comments

can u please suggest me with an example on using webpack? I tried ejecting. But then what? I have no idea.please?
So if ejecting is not a good idea for me, is there an other way to do this?
So cant i use index.jsx format with out ejecting as you mentioned before?
Could you tell me how to do this?
Misleading answer.
|

Your Answer

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