4

I followed the instructions of this tutorial (https://youtu.be/KFyRLxiRKAc) and rewatched it several times but somehow it won't work for me. After I reopen the folder in the devcontainer and run npm start, the app is loading for several minutes until the browser opens localhost:3000 and presents the app. Now if I'm editing Code of the app, like changing the text of the create-react-app it won't reload at all. To detect changes I would have to restart the container but even that would take several minutes.

How can I solve the issue?

EDIT: I already tried setting CHOKIDAR_USEPOLLING=true and FAST_REFRESH=false but neither of them makes a difference

.devcontainer/.env

FAST_REFRESH=false
CHOKIDAR_USEPOLLING=true

.devcontainer/devcontainer.json

{
    "name": "Node.js",
    "build": {
        "dockerfile": "Dockerfile",
        "args": {
            "VARIANT": "16-bullseye"
        }
    },

    "settings": {},
    
    "extensions": [
        "dbaeumer.vscode-eslint"
    ],

    "forwardPorts": [
        3000
    ],

    "postCreateCommand": "npm install && npm start",
    "runArgs": [
        "--env-file",
        ".devcontainer/.env"
    ]
}

.devcontainer/Dockerfile

ARG VARIANT="16-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
Pi 3.1415
  • 41
  • 2
  • Have the same issue with the devcontainer. Have you find the solution yet? – Bryan Fok Feb 19 '23 at 07:44
  • What worked for me is setting the environment variable WATCHPACK_POLLING=true, i.e. `WATCHPACK_POLLING=true npm run ....` This instead of CHOKIDAR_USEPOLLING=true which was suggested elsewhere. Also see https://stackoverflow.com/questions/44643045/running-development-server-with-create-react-app-inside-of-a-docker-container – raymi Jun 15 '23 at 21:49

1 Answers1

0

You should do little bit of search in this forum. I'm quoting the answer:

Adding a .env file in the base path of the project and inside add FAST_REFRESH=false.

This disables fast refresh and returns to hot reload.

Rollin
  • 304
  • 4
  • 13
  • 2
    I did search for a solution here but nothing has worked so far. The .env with FAST_REFRESH=false unfortunataly doesn't make a difference. – Pi 3.1415 Jan 23 '22 at 11:21
  • Have the same issue with the devcontainer. Have you find the solution yet? – Bryan Fok Feb 19 '23 at 07:44