Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm start fails to run in generated project if parent directory contains file named .config #13355

Open
jonhermansen opened this issue Sep 4, 2023 · 2 comments

Comments

@jonhermansen
Copy link

jonhermansen commented Sep 4, 2023

Describe the bug

When bootstrapping a new React app with CRA, I found that npm start fails within my project if a parent directory contains a file named .config.

This issue can be reproduced by running the following in a terminal:

cd $(mktemp -d) && touch .config && npx create-react-app my-app && cd my-app && npm start

Did you try recovering your dependencies?

No, I didn't try to recover -- but my module tree is not corrupted.

This issue occurs with the latest version of NodeJS (20.5.1) and NPM (10.0.0)

Which terms did you search for in User Guide?

Not relevant

Environment

Environment Info:

  current version of create-react-app: 5.0.1
  running from /home/user/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: Linux 6.4 Fedora Linux 38 (Thirty Eight)
    CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
  Binaries:
    Node: 20.5.1 - ~/.nodenv/versions/20.5.1/bin/node
    Yarn: Not Found
    npm: 10.0.0 - ~/.nodenv/versions/20.5.1/bin/npm
  Browsers:
    Chrome: Not Found
  npmPackages:
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    react-scripts: 5.0.1 => 5.0.1 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. cd $(mktemp -d) && touch .config && npx create-react-app my-app && cd my-app && npm start
  2. Observe error output from starting react/webpack server

Expected behavior

Generated React app will start a web server, regardless of files existing outside of the project.

Actual behavior

Failed to compile.

Error: ENOTDIR: not a directory, open '/tmp/tmp.25CMMbunFM/.config/svgrrc'
ERROR in ./src/logo.svg
Module build failed (from ./node_modules/@svgr/webpack/lib/index.js):
Error: ENOTDIR: not a directory, open '/tmp/tmp.25CMMbunFM/.config/svgrrc'

webpack compiled with 1 error

Reproducible demo

https://github.com/jonhermansen/react-config-file-bug

git clone --depth 1 https://github.com/jonhermansen/react-config-file-bug.git
cd react-config-file-bug
npm start
@jonhermansen
Copy link
Author

The root cause of this issue is cosmiconfig/cosmiconfig#313 which is fixed upstream. react-scripts depends on @svgr/webpack, which in turn depends on a version of cosmiconfig with this bug.

See also: puppeteer/puppeteer#10728

@jonhermansen
Copy link
Author

The svgr lib issue is fixed now upstream, once released to npm I can push a PR here...

P.S. I noticed CRA hasn't been updated in a while, is it still being maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant