JavaScript React Basics Understanding State What is State?

Nancy Melucci
seal-mask
.a{fill-rule:evenodd;}techdegree
Nancy Melucci
Front End Web Development Techdegree Student 32,626 Points

Can't restart application...missing script start

I had to shut down my react server at the end of the third unit. Now I can't bring it back. I need getting the above message, and nothing seems to fix it. Has anyone had this issue? How do I fix it.

Brandon White
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

Hi Nancy,

It is possible for you to provide a link to your repo or workspace? It appears that somewhere along the line you’ve lost the script that lets the server know how to run your app. The issue could be as simple as navigating to your package.json and making sure there’s a scripts property with a nested start property. Such as...

package.json
“scripts”: {
  “start”: “node app.js”
}

Perhaps all you need to do is rerun npm install. But I’d be better able to zero in on the reasoning for this error if I could actually view/test your code.

4 Answers

Nancy Melucci
seal-mask
.a{fill-rule:evenodd;}techdegree
Nancy Melucci
Front End Web Development Techdegree Student 32,626 Points

Hi, thanks for responding. I am doing this in Atom (writing the code in Atom and running on Localhost). I've seen that code you are showing. There is already a "scripts" key with this in my package.json file:

 "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },

I am unsure whether to add your block like this...

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
“scripts”: {
  “start”: “node app.js”
}

or add it as a value like this

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
     “start”: “node app.js”
}

When I create package.json, the code block you suggest is not included... How do I edit it correctly? I've tried adding it as a value (the one directly above) and that doesn't help.

Nancy M.

Brandon White
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

Hi Nancy,

The last method would be the appropriate one, but a comma would need to be placed after the "test" key's value, to separate it from "start". Before you do that though, I imagine you're running the command node app.js or npm start in your terminal to run your app, and at some point when you ran that command everything worked correctly?

If so, are there any other package.json files anywhere else within any of the directories within your code base? And if so, does it already have a start script?

Nancy Melucci
seal-mask
.a{fill-rule:evenodd;}techdegree
Nancy Melucci
Front End Web Development Techdegree Student 32,626 Points

Yes, working through the first three stages while watching the Guil show, everything worked great. This is helping me prepare a final project for a class, so I'd like to finish. I am studying for an exam now, later today, I'll take a look at these questions and see what's going on with the latest version of my project folder. Thanks again.

Brandon White
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

If that's the case, then my guess is that you have a package.json file in your project folder that has a start script, but you're running npm start (or whatever your start command is) in a directory within your project folder that doesn't have that start script.

This may not be the issue at all, but if it is make sure you use the cd command to navigate to the right directory (with the package.json file that has the start script—assuming it's there) and run your start command from that directory.

Nancy Melucci
seal-mask
.a{fill-rule:evenodd;}techdegree
Nancy Melucci
Front End Web Development Techdegree Student 32,626 Points

Hi, I failed to notice that my application was in OneDrive Desktop not my local desktop (thanks, Microsoft!) So once I noticed that, I was able to make the application run. Thanks for your patient help. I can't give you a best answer (it's not available for you). But you did mention it..I apparently wasn't in the right folder.