user9580968
user9580968

Reputation:

Renaming index.js to index.jsx in react app

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?

Upvotes: 17

Views: 18088

Answers (3)

yoges nsamy
yoges nsamy

Reputation: 1435

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.

Upvotes: 9

denexapp
denexapp

Reputation: 569

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

Upvotes: 47

user9906968
user9906968

Reputation:

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

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

Upvotes: -10

Related Questions