I start React.js project in VS Code by
npm start
The development server of create-react-app stops when encountered an error by ESlint. And when an error is fixed it never auto refresh the page. It is necessary to refresh browser's page manually by push refresh button or F5.
For example: if i remove some of the closing brackets (which is error by default, not configured by ESlint), the development server stops, but when i place back the bracket, the server automatically refresh the page. But when the error is defined by ESlint (for example "no-trailing-spaces") the development server stops and after fixing the errors it never refresh the page..
Here are the results in pictures:
the server stops when encountered an error by ESlint
after the errors are fixed, the server still show error and never refresh automatically
ps Actually the server refresh ONLY one time on the first fixed error, On every following fixed error, the server never refreshing!
Is there are any way to fix this problem?
Many thanks!
If this doesn't happen, try one of the following workarounds:
It turned out that the problem is not related with ESlint, but with react-scripts version.
Sadly, it took me several days to figure out from where the problem is coming.
First i was thinking that the problem was related with ESlint, but i was wrong.
The Development server doesn't refresh even without ESlint in the project.
After my research i found that the problem comes from react-script versions 4.0.0 and 4.0.1.
The only one workaround at this moment (when react-script 4.0.1 is available and don't work) is to downgrade to react-script 3.4.4.
To achieve that i use following steps:
In the project folder:
1. In "package.json" file change react-scrips version: "react-scripts": "3.4.4"
2. Delete "package-lock.json" file
3. Delete whole folder "node_modules"
4. In the Terminal: npm install
5. In the Terminal: npm start
After these steps, the Development server again refresh like a charm:)
I want to note that the steps above must to work for people which use react-scripts 4.0.0 or 4.0.1 and had the refresh problems from the Development server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.