create-react-app: Unable to Create a New React App Using npx create-react-app
Description
I’ve been facing issues when creating a new React app using the npx create-react-app command for the past 1 1.5 months. Despite trying multiple solutions, the problem persists, making it impossible to set up a new React project.
Steps to Reproduce
- Run the command:
npx create-react-app my-app. - Attempted the following flags to bypass errors:
--force--legacy-peer-deps
- Tried on different systems and environments:
- Operating Systems: Windows 10/11, macOS
- Networks: Airtel and BSNL ISPs
- Tested on various Node.js versions (all managed with NVM):
- 16.x (LTS)
- 18.x (LTS)
- 20.x (LTS)
- 22.x (LTS)
Expected Behavior
After running the npx create-react-app command, a new React app should be successfully created.
Actual Behavior
The command fails to complete successfully. I’ve attached screenshots of the errors encountered below for you to look over.
Attempts to Fix
- Used
--forceand--legacy-peer-depsflags. - Tried different versions of Node.js.
- Tested on different operating systems and networks.
Environment
- OS: Windows 10/11, macOS
- Node.js: 16, 18, 20, and 22 (LTS versions)
- NPM: Latest version (installed with Node.js)
- React: The
npx create-react-appversion is the default fetched by NPM.
Attachments
(Screenshots of the error messages)
Additional Information
This issue has persisted across multiple environments and configurations for over a month. Please let me know if further details or debugging information are needed to assist in resolving this issue.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 12
- Comments: 17
try this command “npx create-react-app@latest react-18-20-5”
I’ve been using this for years in educational examples but now it’s time to move on.
So people, stop wasting your precious time with this unmaintained project. This error has been reported for weeks already.
At least give a chance to other projects like Vite, which work, are maintained, and have amazing documentation and community support.
Here is what you need to get started:
It’s almost the same setup that this tool creates, with the only minor disadvantage that you need to set up tests afterward. But this can also be solved in just 2-3 minutes by following a tutorial.
For now, I found a temporary solution to fix this issue. Use CRA’s default command and then
cdinto the project and install the latest versions ofweb-vitalsandtesting-library/reactdependencies usingnpm install @testing-library/react@latest web-vitals@latest. As @anipnwr7777 suggested, the peers expect different versions, and the CRA installed the newest version of React. Hence, we must get the latest versions of the other dependencies mentioned in the error message.Here’s what resolves it:
I gotta say I’d prefer if this ‘hello world’ program didn’t track and report users’ behaviour with web-vitals. Someone using this is trying out react, not signing up to report anybody’s activity.
This is indeed all very confusing. The reactjs react.dev repo says create-react-app is dead. After using create-react-app and running for the first time, one is presented with the message “babel-preset-react-app is part of the create-react-app project, which is not maintianed anymore.” [sic] However https://github.com/facebook/create-react-app/ has no mention of this, nor does the website. Anyway, the React website does give other options. If you still want to,
npx yarn create react-app xxxseems to be working.@itsRkator There are a bunch of solutions available out there for this issue. React is coming with major v19 but peers are expecting react to be in v18 and hence the issues.
After the error comes up
cdinside the project and install the latest version of peers which will depend on v19 of react and the issue will be resolved.npm install @testing-library/jest-dom@latest @testing-library/react@latest @testing-library/user-event@latest web-vitals@latestafter this
npm startshould fix the issue.This is an unmaintained project (see: https://github.com/reactjs/react.dev/pull/5487).