Home > OS >  How to stop having to npm start after a while, or everytime I make a change on the file?
How to stop having to npm start after a while, or everytime I make a change on the file?

Time:12-20

I just started taking an coursera course on React. Everytime I make a change in the file, I get this message on Firefox:

Unable to connect

Firefox can’t establish a connection to the server at localhost:3000.

So, if I sudo npm startI can access the url again. Also, if too much time passes, I have to sudo npm start again.

Is it how it's supposed to be or is there a way to make it automatic?

CodePudding user response:

I am assuming you are using create-react-app, there is a watch mode in webpack which builds the react app if you change any files but create-react-app doesn't provide this function so there is a script in given gist to provide that functionality

https://gist.github.com/int128/e0cdec598c5b3db728ff35758abdbafd

  • Related