Development server of create-react-app does not auto refresh

后端 未结 17 1555
清酒与你
清酒与你 2020-12-01 07:30

I am following a tutorial on React using create-react-app. The application is created by create-react-app v1.3.0

create-react-app my-app

T

17条回答
  •  爱一瞬间的悲伤
    2020-12-01 08:00

    Edit: This might not be a recommended solution. The solution worked for Docker.

    If using docker with a volume mount, you need to add an .env file in the src folder with the command CHOKIDAR_USEPOLLING=true in it. However, for me this threw an error

    /app/src/App.js: Cannot find module '@babel/parser'

    . To resolve this new error, changing the "react-scripts": "3.4.3" to "react-scripts": "3.4.0" in the package.json file worked. So you depending on your situation you may need to add the .env file and also change the react-scripts version.

    Note: To put a little more context, I was working with docker and the react app files were mounted as a volume in the docker image (so that making changes in the app are directly reflected in the app without rebuilding a docker image). The above solution is based on other solutions posted in the community for docker where people had suggested changing the react scripts version. I don't think this should be a recommended solution. However, since I was doing a tutorial series I wanted to save time and focus on other things.

提交回复
热议问题