2

I'm having an issue in my React environment where I must restart ('npm start') my server every time I want to view an update in the browser. Others seem to be able to simply refresh the browser without the need to restart their servers.

For instance, if I make an update in one of the React Components I can't simply refresh the web page, I have to restart the entire server.

Any suggestions how to fix this issue so I don't need to restart every time?

robhitt
  • 71
  • 2
  • 7
  • What command does `npm start` correspond to? Look in your `package.json`. – Tom Fenech Feb 12 '17 at 23:07
  • Update your node, this seems like you are running a very OLD version. – Win Feb 12 '17 at 23:11
  • I used create-react-app on the most recent application but I still see the issue across all the apps I'm working on whether or not it's pulled code or I start from scratch so I don't suspect it's an issue in my package.json file. Thanks for looking at this. – robhitt Feb 15 '17 at 20:44

4 Answers4

1

This problem was fixed once I moved my application out of my Dropbox directory.

Once I moved the application out of the Dropbox directory I no longer needed to manually restart the server when I made any edit to a React component. Note that the application does work just fine and auto-refresh using Google Drive (linked to the cloud) or a general non-cloud linked folder on my HD.

robhitt
  • 71
  • 2
  • 7
1

I was getting the same problem using Visual Studio Code. When I made changes nothing was showing up. VC gave me a hint by saying

"Visual Studio Code is unable to watch for file changes in this large workspace"

so I found these instructions which solved the problem. Could be related.

When you see this notification, it indicates that the VS Code file watcher is running out of handles because the workspace is large and contains many files. The current limit can be viewed by running:

cat /proc/sys/fs/inotify/max_user_watches

The limit can be increased to its maximum by editing /etc/sysctl.conf and adding this line to the end of the file:

fs.inotify.max_user_watches=524288

The new value can then be loaded in by running sudo sysctl -p. Note that Arch Linux works a little differently, See Increasing the amount of inotify watchers for details.

Community
  • 1
  • 1
0

Check out Create-React-App by Facebook. It has all the essential tools you'll need when developing React apps.

jpdelatorre
  • 3,573
  • 1
  • 20
  • 25
  • I created the most recent app with the `create-react-app` but neither this file or my other React applications I've created from scratch help solve the issue. My upgraded and downgraded different versions of node, however I still must restart the server every time I want to see a change in the chrome browser. It's been a challenge to find an answer to this one. Seems like an isolated issue. I've uninstalled and re-installed node as well. Thanks for looking into this all. – robhitt Feb 15 '17 at 20:42
  • @jpdelatorre `create-react-app` does not do ssr – Mick Nov 08 '17 at 23:04
0

I use a combination of Webpack to bundle the js code and Nodemon for server restart. They both have watch functionality so they can watch the code to see if anything has changed.

Seems to be an norm from my research.

Sequential
  • 1,455
  • 2
  • 17
  • 27