React: You are running create-react-app 4.x which is behind the latest release (5.x)

Last updated on January 6, 2022 A Goodman Loading... One comment

create-react-app is a popular tool that can help you establish a new React project with no need for manual build configuration. You can see the latest releases and the breaking changes of the library here.

This article is about a problem you may encounter when using create-react-app.

The Problem

Recently, when creating a new React app by running the command below:

npx create-react-app my_app_name

I got an error that came along with some hints:

You are running create-react-app 4.0.3, which is behind the latest release (5.0.0).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:

npm uninstall -g create-react-app
yarn global remove create-react-app

The hints weren’t enough

The output message suggested that if I had previously installed create-react-app globally via npm install -g create-react-app, I need to uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app. The purpose of this action is to ensure that npx always uses the latest version of create-react-app.

I followed the instruction and executed this command:

npm uninstall -g create-react-app

But the problem was NOT solved. When I tried to initialize a new React project again, I got the same error.

The Solution

The root of the issue is that npx will search for create-react-app in a central cache and even after you globally uninstall create-react-app, it is still stuck in the npx cache. What you have to do here is to clear that cache. It’s really simple and can be done with a single command:

npx clear-npx-cache

The steps to solve the problem

In summary, here are the steps that you need to take to fix the error:

1. Globally uninstall the create-react-app package:

npm uninstall -g create-react-app

If you’re using a Mac, you might need sudo:

sudo npm uninstall -g create-react-app

2. Clear the npx cache by performing the following command:

npx clear-npx-cache

Then type “y” to confirm:

That’s it. Now you can create a new project as normal:

npx create-react-app my_project
npx create-react-app react_typescript --template typescript

Conclusion

You’ve solved a problem that occurs when working with the recent update of create-react-app. If you’d like to explore more new and awesome things about modern React development, take a look at the following articles:

You can also check our React topic page and Next.js topic page for the latest tutorials and examples.

Subscribe
Notify of
guest
1 Comment
Inline Feedbacks
View all comments
Yagya Joshi
Yagya Joshi
3 months ago

Man you solved the problem. Now is our create-react-app updated to version 5 or we have to keep this process repeating whenever we create a new project. However, you are brilliant. Thank you

You May Also Like