DEV Community

mandalagig
mandalagig

Posted on

npx create-react-app error

Today, I want make a react app with react cli:

npx create-react-app react-dapp
Enter fullscreen mode Exit fullscreen mode

Suddenly, this error comes:

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

We no longer support the 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 latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
Enter fullscreen mode Exit fullscreen mode

After some googling, several solutions appeared.

  • Solution 00

    • If you want to reinstall the create-react-app globally

      • using latest command

        npm install -g create-react-app@latest
        

      OR, if you already know which package version you’ll need to install

      • for example, create-react-app version 5.0.0

        npm install -g create-react-app@5.0.0
        
    • If you want to reinstall the create-react-app on the designated folder,

      go to the folder, open terminal, type:

      npx create-react-app@latest {project name} --use-npm
      

In most cases, the above solution didn't always straight working.

Try some of the options below:

  • Solution 1

    try to uninstall and reinstall it first.

    npm uninstall -g create-react-app
    
  • Solution 2

    If you run this in an older create-react-app version, try this to clear the npx cache:

    npx clear-npx-cache
    
  • Solution 3

    if you got the error:

    sh: 1: node: Permission denied
    

    on the root folder, you can type:

    npm config set user 0
    npm config set unsafe-perm true
    
  • Lastly, if you have broken npm/ yarn packages, go to the main folder and try to remove node_modules.

    For me, as I’m using Linux I just pressed ctrl + alt + t and typed:

    sudo rm -rf node_modules
    

    After that run this command if you are using yarn

    yarn install
    
    

    If you are using npm run this command

    npm install
    

    And check the solutions above, try from up to bottom.

Oldest comments (0)