Could not find a required file. Name: index.js

Whenever I start my npm it shows the below error, I also install npm globally by using this statement( npm install -g create-react-app)I make two practice project but these are number 2nd project, In the first project, I also install npm globally

PS E:\AvatarDemo\AvatarDemoAwesome> cd avatarawesome
PS E:\AvatarDemo\AvatarDemoAwesome\avatarawesome> npm start
> [email protected] start E:\AvatarDemo\AvatarDemoAwesome\avatarawesome
> react-scripts start
Could not find a required file. Name: index.js Searched in: E:\AvatarDemo\AvatarDemoAwesome\avatarawesome\src
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
8

7 Answers

Maybe index.js is not present , check your folder correctly

3

In my case, when I created a new src folder, it wasn't inside my cd. so it gave this error. Dragging the src folder inside the cd solved the error for me

uninstall create-react-app by npm uninstall create-react-app,then reinstall it

Just rename your js file to "index.js"

I have the same problem but this did not help. I just created a new react project by npx create-react-app 'project-name' and just deleted the files inside src folder. then created a new index.js. instead of deleting the src folder for the purpose of creating the react project from scratch. I hope this will help.

In my case I noticed I opened my src folder inside my public folder. I removed my src folder from my public folder and that solved my issue. I hope this helps.

May be you put src folder inside public folder it should be on the same level of public level

-public -src

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like