Home > Software design >  Create a react app and use a npm start command but it is not working
Create a react app and use a npm start command but it is not working

Time:01-15

I am a newbie in react js.When i want to create-react-app-todos-list it is creating but not displaying success message. As a result when i use npm start command it is displaying error.So please help me to fix this error.

//When i am using create-react-app todos-list it is displaying the following in vscode

 npx create-react-app todos-list

Creating a new React app in D:\react\todos-list.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

added 1357 packages in 1m

166 packages are looking for funding
  run `npm fund` for details

//When i am using npm start command it is displaying as like this

PS D:\react> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path D:\react/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'D:\react\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\shaik\AppData\Local\npm-cache\_logs\2022-01-14T14_29_47_642Z-debug.log
PS D:\react>

**Solutions I tried

For create-react-app**
npm uninstall -g create-react-app && npm i -g npm@latest && npm cache clean -f 
and SKIP_PREFLIGHT_CHECK=true

CodePudding user response:

You are not inside todos-list directory: PS D:\react>

Type: cd todos-list then npm start

CodePudding user response:

When you create react app with npx create-react-app you have option to name your project like what you are done npx create-react-app todos-list and another option which is to create the app in the current directory npx create-react-app .

The problem in your case comes from that you named your project and now you have to explicitly navigate to the dir of the project because the package.json is in that dir. The package.json is essential because it contains all the necesary scripts to run your app.

If you are on the same console you need to just type:

cd todos-list

and then:

npm start
  •  Tags:  
  • Related