4

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
  • Could you please show you folder structure in avatarawesome? Commented Jun 24, 2020 at 11:57
  • E:\AvatarDemo\AvatarDemoAwesome\avatarawesome Commented Jun 24, 2020 at 12:00
  • Help me to resolve my issue pls.. Commented Jun 24, 2020 at 12:01
  • I have also one question that why it is necessary to write these piece of statement before making any project (npm install -g create-react-app) or (npx create-react-app my-app) Commented Jun 24, 2020 at 12:04
  • where are you getting the demo code from? Commented Jun 24, 2020 at 12:04

8 Answers 8

3

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

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

3 Comments

Yeh, it is right but I delete the inbuilt src folder and create my own folder and in these folders, I create avatar.js file as it is the right way or wrong pls describe me.
create a file named index.js and import your avatar.js to it and render the index.js to the DOM
or create a App.js file and import all your components to it like your avatar.js and return it there (App.js),after that import your App.js to index.js and render it
1

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

Comments

0

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

Comments

0

Just rename your js file to "index.js"

Comments

0

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.

Comments

0

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.

Comments

0

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

-public -src

Comments

0

I had this same error while running a next app.

The issue was resolved when i moved src (which contained my index.js file) out of public folder making it look this way; my-app/frontend/src

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.