create-react-app is not working since version 4.0.1

88,141

Solution 1

This worked for me:

npx create-react-app@latest your-project-name --use-npm

Solution 2

All of the existing answers are incorrect.

According to the create-react-app docs, create-react-app should not be installed globally:

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.

This is even stated in the error message you recieved:

You are running create-react-app 4.0.0, which is behind the latest release (4.0.1). We no longer support global installation of Create React App.

You must uninstall create-react-app with npm uninstall -g create-react-app.

Then each time you want to create a new React app with create-react-app, use the command npx create-react-app my-app.

So to fix the error you're getting, uninstall create-react-app globally, update npm, clear the cache, and retry creating the app.

Run this in your terminal:

npm uninstall -g create-react-app && npm i -g npm@latest && npm cache clean -f && npx create-react-app@latest my-app --use-npm

Solution 3

I got

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.

so I simply called the package with an explicit version:

npx [email protected] app-name

Solution 4

I also faced this issue after they released v4.0.2.

They have mentioned this:

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.

I resolved the issue by following the below steps:

  1. Uninstall create-react-app v4.0.1:

    # for npm:
    npm uninstall -g create-react-app
    
    # for yarn:
    yarn global remove create-react-app
    
  2. You are not required to install create-react-app in your local directory, so if you do not want to do this then move to step 3. If you want to do this, install v4.0.2 without using the global flag (-g or --global) using the below command:

    # for npm:
    npm i create-react-app
    
    # for yarn:
    yarn add create-react-app
    
  3. You can now create a new React app using the below command:

    # for npx:
    npx create-react-app my-app
    
    # for npm:
    npm init react-app my-app
    
    # for yarn:
    yarn create react-app my-app
    

Solution 5

I also face the same problem but the problem gets solved when I uninstall the create-react-app globally and then again install it globally.

Uninstalling Command:

npm uninstall -g create-react-app

installing Command:

npx create-react-app my-app

if you have an older npm version (npm version < 5.2) then use this command :

npm install -g create-react-app

it solved my problem I hope it will solve yours

Share:
88,141

Related videos on Youtube

Sumanth Hegde
Author by

Sumanth Hegde

Updated on July 08, 2022

Comments

  • Sumanth Hegde
    Sumanth Hegde almost 2 years

    I tried installing create-react-app using npm i create-react-app, npx create-react-app new-app and npm init react-app new-app, but I keep getting this error message:

    You are running create-react-app 4.0.0, which is behind the latest release (4.0.1).
    We no longer support global installation of Create React App.
    

    How can I fix this?

  • arnold
    arnold over 3 years
    Thanks, this is the best answer IMO. I also did a "brew search node" and then node@14 showed up as the latest stable version in brew. So then "brew install node@14" did the trick. One may also need to update the path, but brew will make it clear if needed: export PATH="/usr/local/opt/node@14/bin:$PATH". Then everything works as expected.
  • cobrexus
    cobrexus over 3 years
  • cobrexus
    cobrexus over 3 years
    npm install create-react-app outside of an npm project doesn't do anything. Just running npx create-react-app my-app will create a new React app.
  • cobrexus
    cobrexus over 3 years
    npm install create-react-app outside of an npm project doesn't do anything. Just running npx create-react-app my-app will create a new React app.
  • javedb
    javedb over 3 years
    I would highly recommend installing NVM as the solution would be as simple as switching to the LTS, running create-react-app and then switching back to the node version you were previously on.
  • Alex Hall
    Alex Hall over 3 years
    @ΛRYΛN Running 'npx create-react-app my-app' after uninstalling globally threw the same error as the original post. This did not work. Installing create-react-app without the global flag installed it to my current directory which allowed me to create a new react app but you're correct maybe it's not the best approach. I've found a better way and updated my post above but I'm still trying to figure out where exactly create-react-app is installed if not globally. I don't see it in any of the expect locations, mainly /Users/{username}/.nvm/versions/node/v15.3.0/lib/node_module‌​s/npm/node_modules.
  • Colorful Tones
    Colorful Tones over 3 years
    #2 worked for me. I knew that I had not ever installed create-react-app globally and was confused by all the posts and documentation assuming that users did install it globally. Thanks!
  • Sean256
    Sean256 over 3 years
    I don't have it installed globally and I'm using node 14.15.4, so there is another cause for it. I have yet to figure it out.
  • Auo
    Auo about 3 years
    @Can we use this approach? I am a beginner and not very sure if this will cause any issues in the future?
  • Dashiell Rose Bark-Huss
    Dashiell Rose Bark-Huss about 3 years
    First off, when you uninstall a package you can always undo what you did by reinstalling. You would do this by running in the root of the directory that the package was deleted from- npm install create-react-app or if you want to reinstall the a specific version npm install [email protected]. But I don't think you would need to do that because as I understand it the idea is to use npx which as I understand it doesn't download any packages but uses the package hosted on on the npm registry. So you don't need the create-react-app package on your computer at all to use the package.
  • Dashiell Rose Bark-Huss
    Dashiell Rose Bark-Huss about 3 years
    When you run npx create-react-app new-app you're saying "Hey npm server, please use the create react package on your server to help me create a react app."
  • Suraj Rao
    Suraj Rao about 3 years
    You dont install globally. Read the answer stackoverflow.com/a/65043610/4826457
  • Mazhar Zandsalimi
    Mazhar Zandsalimi about 3 years
    I had the same problem, peeked into my ~/.npm/_npx and found the directory with 4.0.1, when providing the version and creating my react app, npx created the 4.0.2 as well. I wonder if this is a problem with npx not being able to clean it's cache or just being confused?!
  • Matt Croak
    Matt Croak about 3 years
    This was the only thing that worked for me! It's amazing how many errors can be resolved simply updating/reinstalling packages.
  • Tyler2P
    Tyler2P almost 3 years
    There are more detailed answers to answer this question therefore this answer should be a comment instead.
  • Sugan
    Sugan almost 3 years
    Not enough reputations to add it as a comment yet
  • Jo Momma
    Jo Momma over 2 years
    This works....it's important to note, if you use both npm and yarn for different reasons you may run into a situation where you try to uninstall create-react-app with the wrong package manager (not the one you installed it with). In that case, try both the npm and yarn uninstall command....one of them should work
  • Stephen Fong
    Stephen Fong over 2 years
    If anyone is still facing that problem after uninstalling it globally and cleaning the cache, try to run npm uninstall create-react-app as you might have a non-global installation.
  • Omar Zaoujal
    Omar Zaoujal over 2 years
    it worked for me too, but honestly, I don't know why it worked because I've installed it globally again
  • Shai Kimchi
    Shai Kimchi about 2 years
    Holy crap, after doing "yarn add create-react-app" "npx create-react-app" started working again!!! tnx
  • Maka Idfu
    Maka Idfu about 2 years
    I get a "permission denied" when I try to run this command even with sudo before it
  • cobrexus
    cobrexus about 2 years
    @MakaIdfu that means that you are not logged in as the super user on your machine...
  • Brandon Johnson
    Brandon Johnson almost 2 years
    clear the cache is the important piece i was missing thanks