search

Home  >  Q&A  >  body text

`npx create-react-app` cannot be used directly when creating a React project

When I create a React app, I should first run the command "npm install create-react-app" and then "npx create-react-app name", otherwise it will give an error, but others only need to run the second A command, why?

I tried downloading the latest version of Node.js, npm, and clearing the cache, but I still got an error when I tried to run it.

npx create-react-app name

Still need to run npm install create-react-app. Please help me solve this problem.

P粉704066087P粉704066087463 days ago591

reply all(1)I'll reply

  • P粉633075725

    P粉6330757252023-08-10 11:17:12

    You should now no longer need to install create-react-app globally. The recommended way to create new React applications is to use npx

    If you have previously installed create-react-app globally, it may conflict with the latest version. You can try to uninstall it: npm uninstall -g create-react-app

    You can clear the cache using the following command: npm cache verify

    Finally, you can create the app using the following command: npx create-react-app@latest my-app

    reply
    0
  • Cancelreply