Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not find a required file" on `yarn start`

I set up a create-react-app and I'm trying to run App.js on localhost, but upon doing yarn start I get the following error message:

22:23 $ yarn start
yarn run v1.3.2
$ react-scripts start
Could not find a required file.
  Name: index.html
  Searched in: /Users/-----/Desktop/---/----/hw/HW-REPO/hw-name/public
error Command failed with exit code 1.

I'd already installed yarn with yarn install, so I'm not sure if there's something wrong with my code or with the file structure.

Here's the file structure:

app-name
 -client
   --public
     ---index.html
     ---manifest.json
   --src
     ---Components
        ----various folders
     ---App.js
     ---App.test.js
     ---index.js
 -database
 -model
 -gitignore
 -package-lock.json
 -package.json
 -server.js
 -yarn.lock
like image 366
Tsardines Avatar asked Apr 09 '18 02:04

Tsardines


2 Answers

In my case command npm audit fix --force change version of react-scripts in package.json As I created app with --template typescript, older version of react-scripts could not find index.js, but I have index.tsx

I solve this by removing package-lock.json, node-modules folder and remove react-scripts from package.json, then npm i react-scripts

like image 103
Mikhail Makarov Avatar answered Oct 12 '22 18:10

Mikhail Makarov


In my case I opened my wrong folder in vs code and was trying to run npm start from their and npm did not find the index.html in that path, so I looked the correct path and reopened the folder and got no issue. Hope this will help some new beginner.

like image 4
V Jazz Avatar answered Oct 12 '22 19:10

V Jazz