npm start script returns error immediately after installing create-react-app my-first-react-app

As the title states, I just installed the react library and went to start the application for the first time. I’m getting the following error below.

From what I can tell, it seems that the application is looking into the wrong folder to find the starter script. I’ve not altered any of the initial starter files, or added any of my own. I’m unsure how to address this issue.

npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:UsersDavidpackage.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:UsersDavidAppDataRoamingnpm-cache_logs2019-12-28T21_32_24_438Z-debug.log```

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think you forgot to cd into (or to change to) your project’s directory.

Assuming that you initialised your project in the directory C:UsersDavid and gave the project name my-app, just type cd my-app (or to be precise type cd C:UsersDavidmy-app in your Command Prompt and then run npm start.

The file the error message is complaining about, package.json, is already available inside your project folder.

However, installing create-react-app and then initialising a new app is not the new recommended way.

According to the React documentation, uninstall the create-react-app global npm package and follow the following steps to create a new React app:

npx create-react-app my-app
cd my-app
npm start

Note

npx on the first line is not a typo — it’s a package runner tool that
comes with npm 5.2+.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x