facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.69k stars 26.84k forks source link

create-react-app fails on "empty" vscode docker mounted container (.devcontainer folder) #10345

Open trenttobler opened 3 years ago

trenttobler commented 3 years ago

Describe the bug

create-react-app too aggressive when creating a new app about existance of tooling config folders, in this case, ".devcontainer" folder for using vscode to develop inside a docker container.

Environment

  current version of create-react-app: 4.0.1
  running from /home/node/.npm/_npx/4431/lib/node_modules/create-react-app

  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 14.15.1 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.10 - /usr/local/share/npm-global/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^17.0.1 => 17.0.1 
    react-dom: ^17.0.1 => 17.0.1 
    react-scripts: 4.0.1 => 4.0.1 
  npmGlobalPackages:
    create-react-app: Not Found

NOTE: this is inside a docker image, running on Docker Desktop (windows 10), after launching and mounting the application folder using vscode's "Remote Development" extension.

Steps to reproduce

  1. launch vscode , with "Remote Development" extension installed: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack
  2. using extension: 2A. launch "open folder in container..." option for extension 2B. select an empty folder. 2C. Select container image: "node.js & typescript"; select node version 14 (or later) if prompted.
  3. once container has built, and vscode attached, open bash prompt from vscode, and execute create-react-app script to create a new app (in mount folder, E.G: /workspaces/new-app-folder): npx create-react-app . --template typescript

Expected behavior

app template created with "create react app" initial code and logic.

Actual behavior

error message:

The directory . contains files that could conflict:

  .devcontainer/

Reproducible demo

Identical situation can be created by simply creating a folder ".devcontainer" having two empty files: Dockerfile and devcontainer.json -- while these files are not empty in the normal test, the contents are irrelevant to the issue.

VSCode uses these files to automatically relaunch the same docker container if it is opened in any subsequent sequence, or on another host with vscode + docker installed.

Additional notes

In file: https://github.com/facebook/create-react-app/blob/8bf050aa7c16078fed5e51ac8388d6100c29e105/packages/create-react-app/createReactApp.js#L935

there is a list of exceptions to the list of files that are ignored relating to this error. I was able to get this to succeed by hacking the name listed here, and renaming back after completion, E.G:

mv .devcontainer .hg
npx create-react-app . --template typescript
mv .hg .devcontainer
molotch commented 2 years ago

Had same problem, thanks for the "work around".