React npm start not working?

Not sure what’s going on here as Ive just started using React. But when I use create-react-app and then npm start I get a huge error…

Ive tried to find solutions online but have not gotten a working solution yet. Seems that others are having this problem as well. any advise on what I can do to get this up and running?

Screen Shot 2021-06-28 at 8.01.12 PM

error message: no such file or directory, open '/Users/thomas/package.json'

Is the name of your React project ‘thomas’, or did you run npm start from outside the project directory?

2 Likes

No. I ran npm start inside the folder I was to be working in.

My username is Thomas. Im not sure why it would be searching there for a package.json file when I created the react app inside a specific work folder. Im so confused :thinking:

It looks like your folder name is React_Practice.

Is that correct?

If so, I think you have to use a different command.

1 Like

WOOOWW I got it working.

after uninstalling node.js and reinstalling it and searching the web for almost 2 hrs :roll_eyes:

your comment tipped me off. I had to pwd in the terminal to see where I was. apparently, after create-react-app I have to cd into the folder? Its kind of tricky because it REALLY seems as if im inside the folder in vs code because you can see the src files inside and etc. but I guess the directory is still in the original working folder and not the newly created react folder with the new files inside :roll_eyes:

WILD.

Thats why it couldn’t npm start because I was in the original folder and not my app folder (even though I could see inside the app folder using vs code).

Thanks for your help :+1:its good to go now

2 Likes

Ohhh… yeah that is in the docs

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

Yeah my folder was named React_Practice and by using : npx create-react-app “FOLDERNAME” (newly created folder) , I had created a new folder with the project files inside of that but, was still in the original React_Practice folder.

Problem is, in VS code you can peer inside the newly created folder even though that’s not your actual directory.

good thing I learned a few terminal commands. really saved me in this situation :sweat_smile:

Ohh…ok.

I made that same mistake when I first started.

If you have an exisiting folder, then you can run that command from the stackoverflow answer I linked earlier.

Otherwise, you can create a new folder and react app and then open it in vs code.


Glad you got it working!

1 Like

Ahh I see now! that’s a good way of doing it too :face_with_monocle:

nice.

Thanks for help!

Glad you were able to figure it out. I know it can be a bit dry and tedious, but it’s worth it to practice exploring your file system using only the command line terminal; once you get used to it, your efficiency will skyrocket.

1 Like

Thanks. That makes total sense to me now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.